- 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 2010-05-06 21:58 by gsakkis, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | |||
|---|---|---|---|
| File name | Uploaded | Description | Edit |
| inspect.patch | maxbublis, 2011-08-02 00:30 | Adds support for callable objects in inspect.getfullargspec | review |
| Messages (12) | ||
|---|---|---|
| msg105166 - (view) | Author: George Sakkis (gsakkis) | Date: 2010-05-06 21:58 |
Not sure if this has been brought before but how about extending getargspec to work with callable instances, i.e. make it equivalent to getargspec(obj.__call__) ? |
||
| msg116518 - (view) | Author: Marco Mariani (marco.mariani) | Date: 2010-09-16 09:46 |
I second this, I depend on this monkeypatch for my turbogears projects, where I use callable objects as error handlers:
def getargspec(func):
if getattr(func, '__call__') and not isfunction(func) and not ismethod(func):
func = func.__call__
if ismethod(func):
func = func.im_func
if not isfunction(func):
raise TypeError('arg is not a Python function')
args, varargs, varkw = getargs(func.func_code)
return args, varargs, varkw, func.func_defaults
but I suppose 2.7 is locked to this change so I propose it for 3.x
|
||
| msg140069 - (view) | Author: Éric Araujo (eric.araujo) * ![]() |
Date: 2011-07-09 14:27 |
Adding to nosy the developers who last touched inspect. |
||
| msg140106 - (view) | Author: Michael Foord (michael.foord) * ![]() |
Date: 2011-07-11 11:22 |
Doesn't seem like an unreasonable request. Nick / Benjamin, what do you think? |
||
| msg140111 - (view) | Author: Alyssa Coghlan (ncoghlan) * ![]() |
Date: 2011-07-11 12:00 |
This API has changed around a bit in 3.x, so it is actually inspect.getfullargspec that needs to change (getargspec will inherit the new behaviour though, since it uses getfullargspec internally) With appropriate docs and tests updates, I don't see a problem with adding the feature, though. Docs should note and tests should ensure that this only goes one level deep - if __call__ isn't a real function either, inspect shouldn't try to follow the descriptor chain down the rabbit hole. Anything else runs the risk of infinite recursion in the face of things like "inspect.getargspec(list)". |
||
| msg140112 - (view) | Author: Michael Foord (michael.foord) * ![]() |
Date: 2011-07-11 12:01 |
I can produce a patch w/ tests and documentation for you to review Nick. |
||
| msg141536 - (view) | Author: Maxim Bublis (maxbublis) | Date: 2011-08-01 21:44 |
I've ran into the same problem with getfullargspec not supporting callables, so I've written patch with docs and tests, that adds support for any Python callable. As a result of getfullargspec's implementation change, getargspec function also supports callables. |
||
| msg141539 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2011-08-01 22:36 |
I'm -0.5. I think the current patch makes too many assumptions for the caller. For example, someone calling a class may really desire __new__'s signature, not that of __init__. Moreover, conceptually, getargspec() returns the argspec of a directly callable *function* or *method*. |
||
| msg141540 - (view) | Author: Michael Foord (michael.foord) * ![]() |
Date: 2011-08-01 22:44 |
Right. For a callable object (instance with __call__ method), it's unambiguous which signature you want. For a class it's ambiguous. |
||
| msg141541 - (view) | Author: Maxim Bublis (maxbublis) | Date: 2011-08-02 00:30 |
Agree, support for __new__ or __init__ methods would add some ambiquity, so i've decided to drop __init__ support from patch. Patch has been reuploaded. |
||
| msg185929 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2013-04-03 15:05 |
Would someone please review the patch file as it's out of my league. |
||
| msg209681 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2014-01-29 20:55 |
This is now fixed in #17481. |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:00 | admin | set | github: 52885 |
| 2014-01-29 20:55:18 | yselivanov | set | status: open -> closed nosy: + yselivanov messages: + msg209681 dependencies: + inspect.getfullargspec should use __signature__ resolution: fixed |
| 2013-04-03 15:05:27 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg185929 |
| 2011-08-02 13:13:32 | maxbublis | set | files: - inspect.patch |
| 2011-08-02 00:30:25 | maxbublis | set | files:
+ inspect.patch messages: + msg141541 |
| 2011-08-01 22:44:16 | michael.foord | set | messages: + msg141540 |
| 2011-08-01 22:36:14 | benjamin.peterson | set | messages: + msg141539 |
| 2011-08-01 21:44:36 | maxbublis | set | files:
+ inspect.patch nosy: + maxbublis messages: + msg141536 keywords: + patch |
| 2011-07-11 12:01:26 | michael.foord | set | messages: + msg140112 |
| 2011-07-11 12:00:14 | ncoghlan | set | messages:
+ msg140111 title: Allow callable objects in inspect.getargspec -> Allow callable objects in inspect.getfullargspec |
| 2011-07-11 11:22:43 | michael.foord | set | messages: + msg140106 |
| 2011-07-09 20:50:44 | eric.snow | set | nosy:
+ eric.snow |
| 2011-07-09 20:14:10 | daniel.urban | set | nosy:
+ daniel.urban |
| 2011-07-09 14:27:54 | eric.araujo | set | versions: - Python 2.7, Python 3.2 |
| 2011-07-09 14:27:45 | eric.araujo | set | nosy:
+ ncoghlan, eric.araujo, benjamin.peterson, michael.foord messages: + msg140069 |
| 2010-09-16 09:46:42 | marco.mariani | set | nosy:
+ marco.mariani messages: + msg116518 versions: + Python 2.7, Python 3.3 |
| 2010-07-11 15:44:03 | BreamoreBoy | set | versions: - Python 2.7 |
| 2010-05-06 21:58:28 | gsakkis | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements

