Title: inspect.getargspec(print) fails
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.1
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, ubershmekel
Priority: normal Keywords:

Created on 2009-09-14 03:54 by ubershmekel, last changed 2009-09-18 09:14 by georg.brandl. This issue is now closed.

Messages (4)
msg92591 - (view) Author: Yuval Greenfield (ubershmekel) * Date: 2009-09-14 03:54
>>> import inspect
>>> inspect.getargspec(print)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "F:\Python31\lib\", line 787, in getargspec
  File "F:\Python31\lib\", line 814, in getfullargspec
    raise TypeError('arg is not a Python function')
TypeError: arg is not a Python function

Is this normal or a known issue? I couldn't find an existing ticket.
msg92595 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-09-14 09:44
This is not an issue, but a fundamental restriction of what getargspec()
can do.  C function signatures are not introspectable, because basically
every C function can be thought of as defined as either

  def func(*args)


  def func(*args, **kwargs)

and is free to do what it wants with the args and kwargs.
msg92734 - (view) Author: Yuval Greenfield (ubershmekel) * Date: 2009-09-17 00:04
You're right, I was confused by the statement "arg is not a Python 
function". I didn't realize 'arg' meant the function I passed to 
getargspec, I thought it was just strange.

After digging a bit into, may I suggest line 814 be changed 
raise TypeError('arg is not a Python function')

raise TypeError('%s is not a Python function' % func)

That way the error I would have received would have given:
TypeError: <built-in function print> is not a Python function
msg92819 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-09-18 09:14
OK, that is reasonable. I changed this and several other same-style
errors in r74901.
Date User Action Args
2009-09-18 09:14:58georg.brandlsetmessages: + msg92819
2009-09-17 00:04:20ubershmekelsetmessages: + msg92734
2009-09-14 09:44:46georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg92595

resolution: wont fix
2009-09-14 03:54:50ubershmekelcreate