Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspect.getargspec(print) fails #51154

Closed
ubershmekel mannequin opened this issue Sep 14, 2009 · 4 comments
Closed

inspect.getargspec(print) fails #51154

ubershmekel mannequin opened this issue Sep 14, 2009 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ubershmekel
Copy link
Mannequin

ubershmekel mannequin commented Sep 14, 2009

BPO 6905
Nosy @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2009-09-14.09:44:46.575>
created_at = <Date 2009-09-14.03:54:50.034>
labels = ['type-bug', 'library']
title = 'inspect.getargspec(print) fails'
updated_at = <Date 2009-09-18.09:14:58.938>
user = 'https://bugs.python.org/ubershmekel'

bugs.python.org fields:

activity = <Date 2009-09-18.09:14:58.938>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = <Date 2009-09-14.09:44:46.575>
closer = 'georg.brandl'
components = ['Library (Lib)']
creation = <Date 2009-09-14.03:54:50.034>
creator = 'ubershmekel'
dependencies = []
files = []
hgrepos = []
issue_num = 6905
keywords = []
message_count = 4.0
messages = ['92591', '92595', '92734', '92819']
nosy_count = 2.0
nosy_names = ['georg.brandl', 'ubershmekel']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue6905'
versions = ['Python 3.1']

@ubershmekel
Copy link
Mannequin Author

ubershmekel mannequin commented Sep 14, 2009

>>> 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.

@ubershmekel ubershmekel mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 14, 2009
@birkenfeld
Copy link
Member

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.

@ubershmekel
Copy link
Mannequin Author

ubershmekel mannequin commented Sep 17, 2009

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

@birkenfeld
Copy link
Member

OK, that is reasonable. I changed this and several other same-style
errors in r74901.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant