[Python-bugs-list] [ python-Bugs-637217 ] inspect.getargspec: None instead of ()

noreply@sourceforge.net noreply@sourceforge.net
Tue, 12 Nov 2002 08:40:01 -0800


Bugs item #637217, was opened at 2002-11-12 16:40
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=637217&group_id=5470

Category: Python Library
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)

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

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