Skip to content

GH-89519: Deprecate classmethod descriptor chaining #92379

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

Merged
merged 47 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
bbd2da9
Merge pull request #1 from python/master
rhettinger Mar 16, 2021
74bdf1b
Merge branch 'master' of github.com:python/cpython
rhettinger Mar 22, 2021
6c53f1a
Merge branch 'master' of github.com:python/cpython
rhettinger Mar 22, 2021
a487c4f
.
rhettinger Mar 24, 2021
eb56423
.
rhettinger Mar 25, 2021
cc7ba06
.
rhettinger Mar 26, 2021
d024dd0
.
rhettinger Apr 22, 2021
b10f912
merge
rhettinger May 5, 2021
fb6744d
merge
rhettinger May 6, 2021
7f21a1c
Merge branch 'main' of github.com:python/cpython
rhettinger Aug 15, 2021
7da42d4
Merge branch 'main' of github.com:rhettinger/cpython
rhettinger Aug 25, 2021
e31757b
Merge branch 'main' of github.com:python/cpython
rhettinger Aug 31, 2021
f058a6f
Merge branch 'main' of github.com:python/cpython
rhettinger Aug 31, 2021
1fc29bd
Merge branch 'main' of github.com:python/cpython
rhettinger Sep 4, 2021
e5c0184
Merge branch 'main' of github.com:python/cpython
rhettinger Oct 30, 2021
3c86ec1
Merge branch 'main' of github.com:python/cpython
rhettinger Nov 9, 2021
96675e4
Merge branch 'main' of github.com:rhettinger/cpython
rhettinger Nov 9, 2021
de558c6
Merge branch 'main' of github.com:python/cpython
rhettinger Nov 9, 2021
418a07f
Merge branch 'main' of github.com:python/cpython
rhettinger Nov 14, 2021
ea23a8b
Merge branch 'main' of github.com:python/cpython
rhettinger Nov 21, 2021
ba248b7
Merge branch 'main' of github.com:python/cpython
rhettinger Nov 27, 2021
9bc1df1
Merge branch 'main' of github.com:python/cpython
rhettinger Dec 1, 2021
d4466ba
Merge branch 'main' of github.com:python/cpython
rhettinger Dec 1, 2021
a89f02e
Merge branch 'main' of github.com:python/cpython
rhettinger Dec 8, 2021
aae9a5f
Merge branch 'main' of github.com:python/cpython
rhettinger Dec 10, 2021
7ba634b
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 1, 2022
4910ba3
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 5, 2022
0e8d64a
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 9, 2022
7e49f3e
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 10, 2022
6257706
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 18, 2022
2fb7e2c
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 23, 2022
b345021
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 23, 2022
cbb9ace
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 23, 2022
7642c27
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 23, 2022
2320c28
Merge branch 'main' of github.com:python/cpython
rhettinger Jan 30, 2022
9dbc96c
Merge branch 'main' of github.com:python/cpython
rhettinger Feb 3, 2022
c7c9c0f
Merge branch 'main' of github.com:python/cpython
rhettinger Apr 7, 2022
23ed5e3
Merge branch 'main' of github.com:python/cpython
rhettinger Apr 18, 2022
c4f5cd1
Merge branch 'main' of github.com:python/cpython
rhettinger Apr 20, 2022
6b22356
Merge branch 'main' of github.com:python/cpython
rhettinger Apr 20, 2022
adeb3b6
Merge branch 'main' of github.com:python/cpython
rhettinger May 3, 2022
0c8451a
Merge branch 'main' of github.com:python/cpython
rhettinger May 4, 2022
3e57704
Merge branch 'main' of github.com:python/cpython
rhettinger May 4, 2022
39c3b68
Merge branch 'main' of github.com:python/cpython
rhettinger May 6, 2022
dfec23f
GH-89519: Deprecation classmethod decriptor chaining
rhettinger May 6, 2022
99d8edd
Put the deprecation in the main docs.
rhettinger May 6, 2022
061d3d3
Add blurb
rhettinger May 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Doc/howto/descriptor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,8 @@ Using the non-data descriptor protocol, a pure Python version of
if cls is None:
cls = type(obj)
if hasattr(type(self.f), '__get__'):
# This code path was added in Python 3.9
# and was deprecated in Python 3.11.
return self.f.__get__(cls, cls)
return MethodType(self.f, cls)

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

.. testcode::

Expand Down
5 changes: 5 additions & 0 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ are always available. They are listed here in alphabetical order.
``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``) and
have a new ``__wrapped__`` attribute.

.. versionchanged:: 3.11
Class methods can no longer wrap other :term:`descriptors <descriptor>` such as
:func:`property`.


.. function:: compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)

Compile the *source* into a code or AST object. Code objects can be executed
Expand Down
8 changes: 8 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,14 @@ CPython bytecode changes
Deprecated
==========

* Chaining :class:`classmethod` descriptors (introduced in :issue:`19072`)
is now deprecated. It can no longer be used to wrap other descriptors
such as :class:`property`. The core design of this feature was flawed
and caused a number of downstream problems. To "pass-through" a
:class:`classmethod`, consider using the ``__wrapped__`` attribute
that was added in Python 3.10.
(Contributed by Raymond Hettinger in :gh:`89519`.)

* Octal escapes with value larger than ``0o377`` now produce
a :exc:`DeprecationWarning`.
In a future Python version they will be a :exc:`SyntaxWarning` and
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Chaining classmethod descriptors (introduced in bpo-19072) is deprecated. It
can no longer be used to wrap other descriptors such as property(). The
core design of this feature was flawed, and it caused a number of downstream
problems.