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-105080: Fixed inconsistent signature on derived classes#105217

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

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantiangaogaotiantian commentedJun 2, 2023
edited by bedevere-bot
Loading

classB:def__new__(self,*args,**kwargs):returnsuper().__new__(self)def__init__(self,value):self.value=valueclassD1(B):def__init__(self,value):super().__init__(value)classD2(D1):pass

For the code above,inspect.signature(D2) will give a different result thaninspect.signature(D1), which is counter-intuitive. This also affectshelp(D2) vshelp(D1).

We should keep the consistency for the signatures for derived classes (of course when the signature is not changed).

This is due to a corner case ininspect.signature() where only the direct defined__init__ and__new__ method on the class takes priority, then__new__ is always used if defined on any base classes. This fix searches__new__ and__init__ based on MRO and prioritize__new__ if both are defined on a base class.

@gaogaotiantiangaogaotiantian changed the titleFixed inconsistent signature on derived classesgh-105080: Fixed inconsistent signature on derived classesJun 2, 2023
@carljmcarljm merged commit9ad199b intopython:mainJun 2, 2023
@carljmcarljm added the needs backport to 3.12only security fixes labelJun 2, 2023
@miss-islington
Copy link
Contributor

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJun 2, 2023
…honGH-105217)(cherry picked from commit9ad199b)Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
@bedevere-bot
Copy link

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

@bedevere-botbedevere-bot removed the needs backport to 3.12only security fixes labelJun 2, 2023
carljm pushed a commit that referenced this pull requestJun 2, 2023
…-105217) (#105257)gh-105080: Fixed inconsistent signature on derived classes (GH-105217)(cherry picked from commit9ad199b)Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
@gaogaotiantiangaogaotiantian deleted the fix-inconsistent-signature branchJune 3, 2023 03:48
@carljmcarljm added the needs backport to 3.11only security fixes labelJun 3, 2023
@miss-islington
Copy link
Contributor

Thanks@gaogaotiantian for the PR, and@carljm for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry,@gaogaotiantian and@carljm, I could not cleanly backport this to3.11 due to a conflict.
Please backport usingcherry_picker on command line.
cherry_picker 9ad199ba36791711f596393ca9a20dbf118ef858 3.11

gaogaotiantian added a commit to gaogaotiantian/cpython that referenced this pull requestJun 4, 2023
…es (pythonGH-105217).(cherry picked from commit9ad199b)Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
gaogaotiantian added a commit to gaogaotiantian/cpython that referenced this pull requestJun 4, 2023
…es (pythonGH-105217).(cherry picked from commit9ad199b)Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
@bedevere-bot
Copy link

GH-105274 is a backport of this pull request to the3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelJun 4, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@carljmcarljmcarljm approved these changes

@sunmy2019sunmy2019sunmy2019 approved these changes

Assignees

@carljmcarljm

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@gaogaotiantian@miss-islington@bedevere-bot@carljm@sunmy2019

[8]ページ先頭

©2009-2025 Movatter.jp