[Patches] [ python-Patches-637217 ] inspect.getargspec: None instead of ()

SourceForge.net noreply@sourceforge.net
Wed, 21 May 2003 19:27:58 -0700


Patches item #637217, was opened at 2002-11-12 08:40
Message generated for change (Comment added) made by bcannon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=637217&group_id=5470

>Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nathan Srebro (nati)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect.getargspec: None instead of ()

Initial Comment:
When a function has no default arguments, getargspec
(in module inspec) returns a fourth return-value of None:

>>> inspect.getargspec(lambda x:x)
(['x'], None, None, None)

According to the documentation, the fourth return
value, defaults, "is a tuple of default argument
values; if this tuple has n elements, they correspond
to the last n elements listed in args.". This suggests
that if there are no default arguments, an empty tuple
should be returned. This is also more consistent.
Returning None requires special handling in code using
this return value.

Attached is a corrected version of getargspec (a check
for 'defaults is None' is added).

(This bug exists in both 2.2.2 and the current CVS)

----------------------------------------------------------------------

>Comment By: Brett Cannon (bcannon)
Date: 2003-05-21 19:27

Message:
Logged In: YES 
user_id=357491

Making this a patch since it has code.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=637217&group_id=5470