aliles / funcsigs

Python function signatures package for Python 2.6, 2.7 and 3.2+
http://pypi.python.org/pypi/funcsigs
Other
48 stars 33 forks source link

signature() takes first parameter off of unbound methods #2

Closed epsy closed 10 years ago

epsy commented 10 years ago

funcsigs.signature() treats unbound methods as any other method, despite m.self being None.

The attached pull requests adds a test case and fix. I've used a positional-only parameter because of this behaviour:

>>> class Test(object):
...     def method(self, *args, **kwargs):
...         return self, args, kwargs
...
>>> Test.method(Test())
(<__main__.Test object at 0x2c9fad0>, (), {})
>>> Test.method(self=Test())
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: unbound method method() must be called with Test instance as first argument
 (got nothing instead)
aliles commented 10 years ago

Version 0.4 of funcsigs has been published to PyPI which includes epsy's fix for this issue.