Skip to content

Commit be6ebb2

Browse files
itamarofacebook-github-bot
authored andcommitted
GH-89519: Deprecate classmethod descriptor chaining (#92379)
Summary: backporting upstream commit `ebaf0945f9f` (merged upstream [PR GH-92379](python/cpython#92379)), part of upstream issue [GH-89519](python/cpython#89519) Reviewed By: swtaarrs Differential Revision: D50534764 fbshipit-source-id: e74c8910e56f117b3c1cab3442de7394b0bd8b22
1 parent b956d40 commit be6ebb2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Doc/howto/descriptor.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,8 @@ Using the non-data descriptor protocol, a pure Python version of
13491349
if cls is None:
13501350
cls = type(obj)
13511351
if hasattr(type(self.f), '__get__'):
1352+
# This code path was added in Python 3.9
1353+
# and was deprecated in Python 3.11.
13521354
return self.f.__get__(cls, cls)
13531355
return MethodType(self.f, cls)
13541356

@@ -1386,7 +1388,7 @@ Using the non-data descriptor protocol, a pure Python version of
13861388
The code path for ``hasattr(type(self.f), '__get__')`` was added in
13871389
Python 3.9 and makes it possible for :func:`classmethod` to support
13881390
chained decorators. For example, a classmethod and property could be
1389-
chained together:
1391+
chained together. In Python 3.11, this functionality was deprecated.
13901392

13911393
.. testcode::
13921394

Doc/library/functions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ are always available. They are listed here in alphabetical order.
271271
``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``) and
272272
have a new ``__wrapped__`` attribute.
273273

274+
.. versionchanged:: 3.11
275+
Class methods can no longer wrap other :term:`descriptors <descriptor>` such as
276+
:func:`property`.
277+
278+
274279
.. function:: compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)
275280

276281
Compile the *source* into a code or AST object. Code objects can be executed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Chaining classmethod descriptors (introduced in bpo-19072) is deprecated. It
2+
can no longer be used to wrap other descriptors such as property(). The
3+
core design of this feature was flawed, and it caused a number of downstream
4+
problems.

0 commit comments

Comments
 (0)