This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: inspect.getargspec(print) fails
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.1
process
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 2022-04-11 14:56 by admin. 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\inspect.py", line 787, in getargspec
    getfullargspec(func)
  File "F:\Python31\lib\inspect.py", 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)

or 

  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 inspect.py, may I suggest line 814 be changed 
from:
raise TypeError('arg is not a Python function')

to:
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.
History
Date User Action Args
2022-04-11 14:56:52adminsetgithub: 51154
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