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-106917: fix super classmethod calls to non-classmethods#106977

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
carljm merged 4 commits intopython:mainfromcarljm:superfix
Jul 24, 2023

Conversation

@carljm
Copy link
Member

@carljmcarljm commentedJul 21, 2023
edited by bedevere-bot
Loading

The fix for#105035 was subtly incomplete. It checked thatcls->tp_getattro == PyObject_GetGenericAttr (as a precondition for attempting the load-method optimization), but what we really need to know is thatPy_TYPE(self)->tp_getattro == PyObject_GenericGetAttr. In the typical case ofsuper(MyClass, instance)... these are effectively the same thing (instance will be an instance ofMyClass), but in a classmethod super() call (super(MyClass, MyClass)...) they are quite different; the type ofMyClass istype, which has a differenttp_getattro.

For actual classmethods this was fine; the load-method optimization still works correctly for classmethods looked up on types. But it doesn't work for regular methods (plain function objects) looked up on types; those are just regular function calls with no bound method behavior.

It's pretty unusual to use classmethod-stylesuper where the call target is a regular function, not a classmethod. But it can occur, e.g. if usingsuper with__new__ and dynamically-assigned__new__ methods, as in#106917.

* main:pythongh-106004: Add PyDict_GetItemRef() function (python#106005)
@carljmcarljm self-assigned thisJul 21, 2023
Copy link
Member

@Fidget-SpinnerFidget-Spinner left a comment

Choose a reason for hiding this comment

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

Thanks. This is quite the subtlety. LGTM in general. I just have a comment about the tests.

* main: (73 commits)  Thoroughly refactor the cases generator (python#107151)  Docs: Add missing markup to Argument Clinic docs (python#106876)pythongh-107162: Document errcode.h usage in its comment (python#107177)pythongh-106320: Remove private _PyDict C API (python#107145)  Fix PyVectorcall_Function doc versionadded (python#107140)  Docs: Remove duplicate word in Argument Clinic howto heading (python#107169)pythongh-107017: Change Chapter Strings to Texts in the Introduction chapter. (python#107104)pythongh-106320: Remove private _PyObject C API (python#107159)  Docs: fix typo in os.pwrite docstring (python#107087)pythongh-105291: Add link to migration guide for distutils (python#107130)pythongh-106948: Docs: Disable links for C standard library functions, OS utility functions and system calls (python#107062)pythongh-106320: Remove _PyBytes_Join() C API (python#107144)pythongh-106320: Remove private _PyObject C API (python#107147)pythongh-106320: Remove _PyTuple_MaybeUntrack() C API (python#107143)pythongh-106320: Remove _PyIsSelectable_fd() C API (python#107142)  Remove superflous whitespaces in `layout.html`. (pythonGH-107067)pythongh-107122: Update what's news for dbm.*dbm.clear() method (pythongh-107135)pythongh-107122: Add clear method to dbm.ndbm module (pythongh-107126)pythongh-62519: Make pgettext search plurals when translation is not found (python#107118)pythongh-107122: Add clear method to dbm.gdbm.module (pythongh-107127)  ...
@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

Sorry,@carljm, I could not cleanly backport this to3.12 due to a conflict.
Please backport usingcherry_picker on command line.
cherry_picker e5d5522612e03af3941db1d270bf6caebf330b8a 3.12

@carljmcarljm deleted the superfix branchJuly 24, 2023 20:15
carljm added a commit to carljm/cpython that referenced this pull requestJul 24, 2023
…ds (pythonGH-106977).(cherry picked from commite5d5522)Co-authored-by: Carl Meyer <carl@oddbird.net>
@bedevere-bot
Copy link

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

@bedevere-botbedevere-bot removed the needs backport to 3.12only security fixes labelJul 24, 2023
carljm added a commit that referenced this pull requestJul 24, 2023
facebook-github-bot pushed a commit to facebookincubator/cinder that referenced this pull requestMar 30, 2025
Summary:Fixes a couple of issues which are causing `test_super` to fail on 3.12:1) We don't actually respect the global super object at all! We are using the exported Cinder function to implement this on 3.10, but just calling the equivalent of `Ci_Super_Lookup` on 3.12. Because we need to have the `global_super != &PySuper_Type` logic on 3.12 this just brings it over and stops exporting it from Cinder 3.10.3) We get `no_args_in_super_call` backwards as oparg is effectively the number of arguments.2) Ports the fix inpython/cpython#106977 to the implementation of super in both the JIT and Cinder 3.10.Reviewed By: alexmalyshevDifferential Revision: D71638145fbshipit-source-id: 0f5a189d8cea573034e578c921925ce2988c3bb1
facebook-github-bot pushed a commit to facebookincubator/cinderx that referenced this pull requestMar 30, 2025
Summary:Fixes a couple of issues which are causing `test_super` to fail on 3.12:1) We don't actually respect the global super object at all! We are using the exported Cinder function to implement this on 3.10, but just calling the equivalent of `Ci_Super_Lookup` on 3.12. Because we need to have the `global_super != &PySuper_Type` logic on 3.12 this just brings it over and stops exporting it from Cinder 3.10.3) We get `no_args_in_super_call` backwards as oparg is effectively the number of arguments.2) Ports the fix inpython/cpython#106977 to the implementation of super in both the JIT and Cinder 3.10.Reviewed By: alexmalyshevDifferential Revision: D71638145fbshipit-source-id: 0f5a189d8cea573034e578c921925ce2988c3bb1
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Fidget-SpinnerFidget-SpinnerFidget-Spinner approved these changes

@sunmy2019sunmy2019Awaiting requested review from sunmy2019

Assignees

@carljmcarljm

Labels

None yet

Projects

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@carljm@miss-islington@bedevere-bot@Fidget-Spinner@JelleZijlstra

[8]ページ先頭

©2009-2025 Movatter.jp