-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Incorrect behavior of inspect.signature(f).bind #87106
Comments
>>> def foo(a, /, b=1, **kwargs): pass
...
>>> foo(a=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: foo() missing 1 required positional argument: 'a'
>>> inspect.signature(foo).bind(a=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "\Python\Python39\lib\inspect.py", line 3062, in bind
return self._bind(args, kwargs)
File "\Python\Python39\lib\inspect.py", line 2958, in _bind
raise TypeError(msg) from None
TypeError: 'a' parameter is positional only, but was passed as a keyword There is a different behaviour between a simple function call and inspect.signature(foo).bind - different TypeError messages. I think inspect should check for VARKEYWORDS before throwing an error and throw only if there are not. |
slavkostrov
mannequin
added
3.8 (EOL)
end of life
3.9
only security fixes
type-bug
An unexpected behavior, bug, or error
labels
Jan 16, 2021
In another case, inspect.signature(foo).bind gives a TypeError when no TypeError is even raised in the actual call: >>> def foo(a=0, /, b=1, **kwargs): pass
...
>>> foo(a=1)
>>> inspect.signature(foo).bind(a=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/inspect.py", line 3037, in bind
return self._bind(args, kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/inspect.py", line 2933, in _bind
raise TypeError(msg) from None
TypeError: 'a' parameter is positional only, but was passed as a keyword |
jacobtylerwalls
added a commit
to jacobtylerwalls/cpython
that referenced
this issue
Apr 10, 2023
…nly arguments with `**kwargs`
serhiy-storchaka
pushed a commit
that referenced
this issue
May 13, 2024
…guments with **kwargs (GH-103404)
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
May 13, 2024
…nly arguments with **kwargs (pythonGH-103404) (cherry picked from commit 9c15202) Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
May 13, 2024
…nly arguments with **kwargs (pythonGH-103404) (cherry picked from commit 9c15202) Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
serhiy-storchaka
pushed a commit
that referenced
this issue
May 13, 2024
serhiy-storchaka
pushed a commit
that referenced
this issue
May 13, 2024
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
…nly arguments with **kwargs (pythonGH-103404)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
bugs.python.org fields:
Linked PRs
inspect.signature.bind
handling of positional-only arguments with**kwargs
#103404The text was updated successfully, but these errors were encountered: