Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-87106: Fixinspect.signature.bind handling of positional-only arguments with**kwargs#103404

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
serhiy-storchaka merged 17 commits intopython:mainfromjacobtylerwalls:issue-87106
May 13, 2024

Conversation

jacobtylerwalls
Copy link
Contributor

@jacobtylerwallsjacobtylerwalls commentedApr 10, 2023
edited
Loading

gh-87106
Closes#87106

If a function signature has a variadic keyword argument (like**kwargs), then providing a keyword with the same name as a positional-only argument will still succeed, and become available onkwargs.

Before
inspect.signature(f).bind(pos_only='val') might either:

  • raise TypeError unnecessarily if the positional-only arg had a default
  • raise TypeError with a different flavor of error message than runtime (runtime mentions themissing positional arg, but bind() mentioned the name collision, which wasn't the problem)

Now
These are fixed.

Prior related work
#16800

Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks!

@jacobtylerwalls
Copy link
ContributorAuthor

👋@sobolevn would you be interested to take another look?

Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I agree with the fix in general. However, there are still some things to polish and improve :)

Thanks a lot for your work!

jacobtylerwalls reacted with thumbs up emoji
@jacobtylerwalls
Copy link
ContributorAuthor

jacobtylerwalls commentedMay 5, 2024
edited
Loading

Thanks for your suggestions,@sobolevn. Should I move some of the new cases totest_signature_bind_posonly_kwargs()?

Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@serhiy-storchaka do you have any additional feedback?

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM.

@serhiy-storchakaserhiy-storchaka merged commit9c15202 intopython:mainMay 13, 2024
@serhiy-storchakaserhiy-storchaka added needs backport to 3.12only security fixes needs backport to 3.13bugs and security fixes labelsMay 13, 2024
@miss-islington-app
Copy link

Thanks@jacobtylerwalls for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks@jacobtylerwalls for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 13, 2024
…nly arguments with **kwargs (pythonGH-103404)(cherry picked from commit9c15202)Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 13, 2024
…nly arguments with **kwargs (pythonGH-103404)(cherry picked from commit9c15202)Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
@bedevere-app
Copy link

GH-118984 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelMay 13, 2024
@bedevere-app
Copy link

GH-118985 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelMay 13, 2024
serhiy-storchaka pushed a commit that referenced this pull requestMay 13, 2024
…only arguments with **kwargs (GH-103404) (GH-118984)(cherry picked from commit9c15202)Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
serhiy-storchaka pushed a commit that referenced this pull requestMay 13, 2024
…only arguments with **kwargs (GH-103404) (#118985)(cherry picked from commit9c15202)Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
@jacobtylerwallsjacobtylerwalls deleted the issue-87106 branchFebruary 15, 2025 23:42
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@sobolevnsobolevnsobolevn approved these changes

@larryhastingslarryhastingsAwaiting requested review from larryhastings

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Incorrect behavior of inspect.signature(f).bind
4 participants
@jacobtylerwalls@serhiy-storchaka@sobolevn@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp