Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-89519: Remove classmethod descriptor chaining, deprecated since 3.11 #110163

Merged

Conversation

rhettinger
Copy link
Contributor

@rhettinger rhettinger commented Sep 30, 2023

@rhettinger rhettinger added type-bug An unexpected behavior, bug, or error 3.13 bugs and security fixes labels Sep 30, 2023
@rhettinger
Copy link
Contributor Author

I'm still working on the doctest for the descriptor howto. It looks like the classmethod emulation is imperfect after the classproperty has been removed.

@KevinMGranger
Copy link

@rhettinger
Copy link
Contributor Author

@KevinMGranger The examples for combining abstractmethod with classmethod and staticmethod will still work. This is tested in test_abstractclassmethod_basics() in Lib/test/test_abc. Also, here's a live demonstration:

% ./python.exe
Python 3.13.0a0 (heads/remove_classmethod_descriptor_chaining:8336eb0b87, Oct 24 2023, 14:41:05) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from abc import ABC, abstractmethod
>>> class C(ABC):
...     @classmethod
...     @abstractmethod
...     def my_abstract_classmethod(cls, arg):
...         ...
...
>>> C()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Can't instantiate abstract class C without an implementation for abstract method 'my_abstract_classmethod'

Note, these examples have worked since Python 3.3 which was long before the broken descriptor chaining arrived in Python 3.9. So, they are independent of the change being reverted. Thanks for asking.

facebook-github-bot pushed a commit to facebookincubator/cinder that referenced this pull request Oct 25, 2023
…11 (#110163)

Summary: backporting [Raymond Hettinger's `remove_classmethod_descriptor_chaining` branch](https://github.com/rhettinger/cpython/tree/remove_classmethod_descriptor_chaining) (pending upstream PR [GH-110163](python/cpython#110163)), part of upstream issue [GH-89519](python/cpython#89519)

Reviewed By: swtaarrs

Differential Revision: D50534886

fbshipit-source-id: 05b29193ce220f0d91fd0df8d5cef34d7e923456
@itamaro
Copy link
Contributor

itamaro commented Oct 26, 2023

Looking forward to see this getting merged!

fwiw, I ran into an issue related to classmethod descriptor chaining in the Meta codebase -- some code (that was written for Python 3.8, doing a bunch of signature and type inspection of decorated methods) started breaking under Python 3.10.
I backported the deprecation from 3.11 and this removal into Cinder 3.10, and it resolved the issue.

If it helps with confidence in the removal - this PR (cleanly backported to 3.10) is running in production (in Instagram and other Meta Python services), after all internal test suites passed (including the full Instagram test suite).

@rhettinger
Copy link
Contributor Author

@itamaro Thank you for your comment. Indeed, it does increase the confidence in the PR.

@rhettinger rhettinger added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 27, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @rhettinger for commit 291ed52 🤖

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 27, 2023
@rhettinger rhettinger merged commit 7f9a99e into python:main Oct 27, 2023
44 of 57 checks passed
@rhettinger rhettinger deleted the remove_classmethod_descriptor_chaining branch October 27, 2023 05:25
facebook-github-bot pushed a commit to facebookincubator/cinder that referenced this pull request Dec 22, 2023
…ted since 3.11)

Summary:
backport upstream PRs python/cpython#110163 and python/cpython#113233

upstream issues: python/cpython#89519 (Calling help executes classmethod property decorated methods) and python/cpython#113157 (Changed behavior of <instancemethod>.__get__ in Python 3.11)

upstream commits: [`7f9a99e8549b792662f2cd28bf38a4d4625bd402`](python/cpython@7f9a99e) and [`d058eaeed44766a8291013b275ad22f153935d3b`](python/cpython@d058eae)

Reviewed By: aleivag

Differential Revision: D52014322

fbshipit-source-id: 87de6d9587bd9cc49f053ca340adfc469b041f91
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants