Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-130164: Fix inspect.Signature.bind() handling of positional-only args without defaults#130192
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
Conversation
jacobtylerwalls commented Feb 16, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
…only arguments without defaults Follow-up to 9c15202.
| (1, 2, 3, 42, 50,{'c_po': 4})) | ||
| withself.assertRaisesRegex(TypeError, "missing 2 required positional arguments"): | ||
| withself.assertRaisesRegex(TypeError, "missing a required positional-only argument: 'a_po'"): |
jacobtylerwallsFeb 16, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these cases could be moved to the existing method test_signature_bind_posonly_kwargs() if desired?
dfremont left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the very quick fix, @jacobtylerwalls! The new logic looks correct to me and does fix the bug I reported (the exception message is slightly different than a direct call to the function, but I at least don't care about that).
skirpichev commented Feb 17, 2025
CC @picnixz |
jacobtylerwalls commented Feb 17, 2025
Thanks for the review (and the original report!)
Right, this was something I was trying to keep to in the original PR (#103404), but during review discussion there I became convinced it was of only marginal benefit. (This time around it seemed too complicated to be worth it, on first look anyway.) |
serhiy-storchaka left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
dab456d into python:mainUh oh!
There was an error while loading. Please reload this page.
Thanks @jacobtylerwalls for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…only args without defaults (pythonGH-130192) Follow-up to 9c15202. (cherry picked from commit dab456d) Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
GH-130271 is a backport of this pull request to the 3.13 branch. |
Thanks @jacobtylerwalls for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
…only args without defaults (pythonGH-130192) Follow-up to 9c15202. (cherry picked from commit dab456d) Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
GH-132259 is a backport of this pull request to the 3.12 branch. |
Before
inspect.Signature.bind()failed to raise TypeError for positional-only arguments passed by keyword (due to a regression handling the case where a default is defined).After
This is fixed.
Regression in 9c15202.
Interestingly, we did have a test case for this, but it unexpectedly passed because after calling
bind(), the test helper also calls the underlying function, makingassertRaises(TypeError, ...succeed regardless of the behavior ofbind().Closes#130164