classification
Title: cannot pass kwarg `func` to `inspect.getcallargs`
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: joostvanzwieten, python-dev
Priority: normal Keywords:

Created on 2014-01-02 17:29 by joostvanzwieten, last changed 2014-01-02 18:27 by python-dev. This issue is now closed.

Messages (2)
msg207177 - (view) Author: Joost van Zwieten (joostvanzwieten) Date: 2014-01-02 17:29
Consider the following example.

    import inspect
    inspect.getcallargs(lambda **kwargs: None, func=1)

IMHO `getcallargs` should return

    {'kwargs': {'func': 1}}

however, Python (versions 3.3 and 3.4) throws the following exception instead:

    TypeError: getcallargs() got multiple values for argument 'func'

This can be easily solved in `lib/inspect.py` by changing

    def getcallargs(func, *positional, **named):

into

    def getcallargs(*func_and_positional, **named):
        func, *positional = func_and_positional

Best regards,

Joost van Zwieten
msg207179 - (view) Author: Roundup Robot (python-dev) Date: 2014-01-02 18:27
New changeset b0d472e3ff42 by Benjamin Peterson in branch '3.3':
avoid parameter name clash (closes #20108)
http://hg.python.org/cpython/rev/b0d472e3ff42

New changeset c265675cd8e2 by Benjamin Peterson in branch 'default':
merge 3.3 (closes #20108)
http://hg.python.org/cpython/rev/c265675cd8e2
History
Date User Action Args
2014-01-02 18:27:05python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg207179

resolution: fixed
stage: resolved
2014-01-02 17:29:15joostvanzwietencreate