Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks@gaogaotiantian for the PR, and@carljm for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
…honGH-105217)(cherry picked from commit9ad199b)Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
bedevere-bot commentedJun 2, 2023
GH-105257 is a backport of this pull request to the3.12 branch. |
Thanks@gaogaotiantian for the PR, and@carljm for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry,@gaogaotiantian and@carljm, I could not cleanly backport this to |
…es (pythonGH-105217).(cherry picked from commit9ad199b)Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
…es (pythonGH-105217).(cherry picked from commit9ad199b)Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
bedevere-bot commentedJun 4, 2023
GH-105274 is a backport of this pull request to the3.11 branch. |
Uh oh!
There was an error while loading.Please reload this page.
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 in
inspect.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.