Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-137317: fix inspect signature of class with descriptor wrapper#137862
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Signed-off-by: GitHub <noreply@github.com>
python-cla-botbot commentedAug 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.
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
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.
Thank you for your PR,@yanyongyu. LGTM. 👍
I only have few minor suggestions for tests.
| withself.subTest('partial'): | ||
| classC: | ||
| __init__=identity(functools.partial(lambdax,a,b:None,2)) |
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.
Should not this befunctools.partial(identity(lambda x, a, b: None), 2)? Although the "partial" and "partialmethod" subtests are not affected by all these changes, so I am not sure that it makes sense to keep them. If they do not fail, we cannot be sure that they are meaningful.
yanyongyuAug 28, 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.
Thank you for pointing out the error, I will correct this.
These test cases are based on the ones below (test_signature_on_class_with_init andtest_signature_on_class_with_new), and I believe they need to be this detailed to catch potential bugs from changes made ininspect.signature's behavior.
Uh oh!
There was an error while loading.Please reload this page.
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.
LGTM. 👍
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
I added also tests for a wrapped metaclass' |
025a213 intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@yanyongyu for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
Thanks@yanyongyu for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…t__ or __new__ (pythonGH-137862)Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptorthat returns a wrapped function.(cherry picked from commit025a213)Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
…t__ or __new__ (pythonGH-137862)Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptorthat returns a wrapped function.(cherry picked from commit025a213)Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
GH-138224 is a backport of this pull request to the3.14 branch. |
GH-138225 is a backport of this pull request to the3.13 branch. |
…t__ or __new__ (pythonGH-137862)Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptorthat returns a wrapped function.(cherry picked from commit025a213)Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
…t__ or __new__ (pythonGH-137862)Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptorthat returns a wrapped function.
…it__ or __new__ (GH-137862) (#138224)gh-137317: Fix inspect.signature() for class with wrapped __init__ or __new__ (GH-137862)Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptorthat returns a wrapped function.(cherry picked from commit025a213)Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
This PR fixes the
inspect.signaturebehavior when inspecting a class that uses descriptor (like classmethod/staticmethod/custom) with a wrapped__init__.This PR also adds more test cases not covered in PR#132055.
cyfunction __init__due to unwrap and descriptor behavior changed #137317