GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-130164: Fix inspect.Signature.bind() handling of positional-only args without defaults by jacobtylerwalls · Pull Request #130192 · python/cpython

Conversation

@jacobtylerwalls

@jacobtylerwalls jacobtylerwalls commented Feb 16, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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, making assertRaises(TypeError, ... succeed regardless of the behavior of bind().

Closes #130164

  • Issue: Signature.bind allows certain positional-only parameters as keywords #130164

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jacobtylerwalls
pythongh-130164: Fix inspect.signature.bind() handling of positional-…
dd20797
…only arguments without defaults

Follow-up to 9c15202.
@bedevere-app bedevere-app Bot added the awaiting review label Feb 16, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Feb 16, 2025
Signature.bind allows certain positional-only parameters as keywords #130164
Closed
@jacobtylerwalls
Fix typo
4a0b38a
jacobtylerwalls
jacobtylerwalls commented Feb 16, 2025
View reviewed changes
Comment thread Lib/test/test_inspect/test_inspect.py
(1, 2, 3, 42, 50, {'c_po': 4}))

with self.assertRaisesRegex(TypeError, "missing 2 required positional arguments"):
with self.assertRaisesRegex(TypeError, "missing a required positional-only argument: 'a_po'"):

@jacobtylerwalls jacobtylerwalls Feb 16, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jacobtylerwalls jacobtylerwalls changed the title gh-130164: Fix inspect.signature.bind() handling of positional-only args without defaults gh-130164: Fix inspect.Signature.bind() handling of positional-only args without defaults Feb 16, 2025
dfremont
dfremont approved these changes Feb 16, 2025
View reviewed changes

@dfremont dfremont left a comment

Copy link
Copy Markdown

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).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Feb 16, 2025
@skirpichev

skirpichev commented Feb 17, 2025

Copy link
Copy Markdown
Member

CC @picnixz

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

skirpichev
skirpichev approved these changes Feb 17, 2025
View reviewed changes
@jacobtylerwalls

jacobtylerwalls commented Feb 17, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for the review (and the original report!)

(the exception message is slightly different than a direct call to the function, but I at least don't care about that).

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.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka approved these changes Feb 18, 2025
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

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. 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 18, 2025
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.13 only security fixes label Feb 18, 2025
@serhiy-storchaka
serhiy-storchaka merged commit dab456d into python:main Feb 18, 2025
@miss-islington-app

miss-islington-app Bot commented Feb 18, 2025

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 18, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 18, 2025
@jacobtylerwalls @miss-islington
pythongh-130164: Fix inspect.Signature.bind() handling of positional-…
d6931c5
…only args without defaults (pythonGH-130192)

Follow-up to 9c15202.
(cherry picked from commit dab456d)

Co-authored-by: Jacob Walls <[email protected]>
@bedevere-app

bedevere-app Bot commented Feb 18, 2025

Copy link
Copy Markdown

GH-130271 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Feb 18, 2025
@jacobtylerwalls
jacobtylerwalls deleted the fix-130164 branch February 18, 2025 16:27
serhiy-storchaka pushed a commit that referenced this pull request Apr 8, 2025
@miss-islington @jacobtylerwalls
[3.13] gh-130164: Fix inspect.Signature.bind() handling of positional…
5c658c1
…-only args without defaults (GH-130192) (GH-130271)

Follow-up to 9c15202.
(cherry picked from commit dab456d)

Co-authored-by: Jacob Walls <[email protected]>
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.12 only security fixes label Apr 8, 2025
@miss-islington-app

miss-islington-app Bot commented Apr 8, 2025

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 8, 2025
@jacobtylerwalls @miss-islington
pythongh-130164: Fix inspect.Signature.bind() handling of positional-…
ecdf998
…only args without defaults (pythonGH-130192)

Follow-up to 9c15202.
(cherry picked from commit dab456d)

Co-authored-by: Jacob Walls <[email protected]>
@bedevere-app

bedevere-app Bot commented Apr 8, 2025

Copy link
Copy Markdown

GH-132259 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Apr 8, 2025
serhiy-storchaka pushed a commit that referenced this pull request Apr 8, 2025
@miss-islington @jacobtylerwalls
[3.12] gh-130164: Fix inspect.Signature.bind() handling of positional…
40f81e1
…-only args without defaults (GH-130192) (GH-132259)

Follow-up to 9c15202.
(cherry picked from commit dab456d)

Co-authored-by: Jacob Walls <[email protected]>
@ryanking13 ryanking13 mentioned this pull request Aug 2, 2025
Fix test_relaxed_call for Python 3.13 TypeError message format pyodide/pyodide#5813
Merged
2 tasks
Drranny added a commit to Drranny/pyodide that referenced this pull request Aug 2, 2025
@Drranny
Add comment about TypeError message change in Python 3.13.3 (python/c…
0b02fcb
…python#130192)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@skirpichev skirpichev skirpichev approved these changes
@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
+1 more reviewer
@dfremont dfremont dfremont approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Signature.bind allows certain positional-only parameters as keywords

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@jacobtylerwalls @skirpichev @dfremont @serhiy-storchaka
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.