gh-89519: Remove classmethod descriptor chaining, deprecated since 3.11 by rhettinger 路 Pull Request #110163 路 python/cpython (original) (raw)
@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.