- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
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.
Created on 2012-11-17 03:36 by jcea, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Messages (11) | ||
|---|---|---|
| msg175725 - (view) | Author: Jesús Cea Avión (jcea) * ![]() |
Date: 2012-11-17 03:36 |
Yesterday I was attending a conference about a MOCK like library and the speaker told us about some "inspect" functionalities not working correctly with builtins. For instance:
"""
Python 3.3.0 (default, Oct 2 2012, 02:07:16)
[GCC 4.4.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> def f(a=None) :
... pass
...
>>> inspect.getcallargs(f)
{'a': None}
>>> inspect.getargspec(f)
ArgSpec(args=['a'], varargs=None, keywords=None, defaults=(None,))
>>> inspect.getcallargs(list)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.3/inspect.py", line 993, in getcallargs
spec = getfullargspec(func)
File "/usr/local/lib/python3.3/inspect.py", line 850, in getfullargspec
raise TypeError('{!r} is not a Python function'.format(func))
TypeError: <class 'list'> is not a Python function
>>> inspect.getargspec(list)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.3/inspect.py", line 823, in getargspec
getfullargspec(func)
File "/usr/local/lib/python3.3/inspect.py", line 850, in getfullargspec
raise TypeError('{!r} is not a Python function'.format(func))
TypeError: <class 'list'> is not a Python function
>>>
"""
Can we annotate builtins to support this?. What about types defined in CModules?
|
||
| msg175726 - (view) | Author: Jesús Cea Avión (jcea) * ![]() |
Date: 2012-11-17 03:51 |
I am fully aware that the interpreter doesn't know how a method/function written in C is going to parse the parameter list/keywords. And that even if we solve this (for instance, with annotations that create wrappers calling "PyArg_Parse()" automatically), every C extension out there would need to support it too. Just brainstorming. |
||
| msg175745 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2012-11-17 14:46 |
So at this point you should use inspect.signature(), not getfullargspec(). With that you could do this if you either allowed setting the __signature__ attribute and then provided code that would set it, made __signature__ a property that returned the Signature object if desired on a built-in, or come up with some automated way to take the argument string from PyArg_Parse() as you suggested. |
||
| msg175752 - (view) | Author: Larry Hastings (larry) * ![]() |
Date: 2012-11-17 15:08 |
I'm working on a solution for this--expect an announcement on c.l.p-d in, oh, a week. |
||
| msg176693 - (view) | Author: Jesús Cea Avión (jcea) * ![]() |
Date: 2012-11-30 16:45 |
Larry, Ping... :-) |
||
| msg176867 - (view) | Author: Larry Hastings (larry) * ![]() |
Date: 2012-12-03 22:49 |
http://mail.python.org/pipermail/python-dev/2012-December/122920.html |
||
| msg176878 - (view) | Author: David Villa Alises (david.villa) | Date: 2012-12-04 08:06 |
What about something like gobject.introspection? https://live.gnome.org/GObjectIntrospection/ |
||
| msg177022 - (view) | Author: Jesús Cea Avión (jcea) * ![]() |
Date: 2012-12-06 01:25 |
David, please subscribe to Issue #16612. |
||
| msg177221 - (view) | Author: Berker Peksag (berker.peksag) * ![]() |
Date: 2012-12-09 14:14 |
This looks like a duplicate of issue 1748064. |
||
| msg207922 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2014-01-11 23:21 |
This is related to issue #17481 |
||
| msg209475 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2014-01-27 20:34 |
Closing this issue. See #17481 for details. |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:38 | admin | set | github: 60694 |
| 2014-01-27 20:34:56 | yselivanov | set | status: open -> closed resolution: duplicate messages: + msg209475 |
| 2014-01-11 23:21:19 | yselivanov | set | nosy:
+ yselivanov messages: + msg207922 |
| 2012-12-11 11:11:46 | asvetlov | link | issue1748064 superseder |
| 2012-12-09 14:14:25 | berker.peksag | set | nosy:
+ berker.peksag messages: + msg177221 |
| 2012-12-06 01:25:46 | jcea | set | messages: + msg177022 |
| 2012-12-04 08:06:09 | david.villa | set | messages: + msg176878 |
| 2012-12-03 22:49:39 | larry | set | messages: + msg176867 |
| 2012-11-30 16:45:08 | jcea | set | messages: + msg176693 |
| 2012-11-22 12:09:16 | david.villa | set | nosy:
+ david.villa |
| 2012-11-17 15:08:18 | larry | set | assignee: larry |
| 2012-11-17 15:08:11 | larry | set | messages: + msg175752 |
| 2012-11-17 14:46:45 | brett.cannon | set | nosy:
+ brett.cannon, larry messages: + msg175745 |
| 2012-11-17 14:18:01 | asvetlov | set | nosy:
+ asvetlov |
| 2012-11-17 03:51:52 | jcea | set | messages: + msg175726 |
| 2012-11-17 03:37:29 | jcea | set | type: enhancement |
| 2012-11-17 03:37:17 | jcea | set | title: "inspect.getargspec()" and "inspect.getcallargs()" don't work with builtins -> "inspect.getargspec()" and "inspect.getcallargs()" don't work for builtins |
| 2012-11-17 03:36:29 | jcea | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements

