Issue 637217: inspect.getargspec: None instead of () (original) (raw)
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)