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.

Author productivememberofsociety666
Recipients productivememberofsociety666
Date 2015-03-24.18:14:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427220873.41.0.520106438504.issue23764@psf.upfronthosting.co.za>
In-reply-to
Content
functools.wraps currently only changes the wrapped function's "superficial" attributes such as docstring or annotations.

But it would be useful to be able to change the function's actual argspec as well so it matches up with the changed annotations (e.g. to get proper error messages when the wrapped and wrapper functions' argspecs don't match up).

To avoid breaking existing code, this could be achieved by adding another argument change_argspec (defaulting to False) to functools.wraps. Of course, the way functools.wraps is implemented now as well as its current documentation would have to be thrown out of the window in order for this to work (at least for the case of change_argspec==True).


There is an existing 3rd party package ( https://pypi.python.org/pypi/decorator ) which has a decorator called "decorator" that does kind of what I'd want functools.wraps to do, but the details of how it is called are different and either way it's embarassing that you have to fall back on a 3rd party library to get functionality that is present but incomplete in Python's standard library.
History
Date User Action Args
2015-03-24 18:14:33productivememberofsociety666setrecipients: + productivememberofsociety666
2015-03-24 18:14:33productivememberofsociety666setmessageid: <1427220873.41.0.520106438504.issue23764@psf.upfronthosting.co.za>
2015-03-24 18:14:33productivememberofsociety666linkissue23764 messages
2015-03-24 18:14:33productivememberofsociety666create