From 2964a3839d1b063087338a78937344241c1c3869 Mon Sep 17 00:00:00 2001 From: Yahor Harunovich Date: Fri, 23 Apr 2021 01:56:00 +0300 Subject: [PATCH] Fix descriptor documentation typo --- Doc/howto/descriptor.rst | 4 ++-- .../2021-04-22-23-18-26.bpo-bpo-43917.d-1T5G.rst | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Documentation/2021-04-22-23-18-26.bpo-bpo-43917.d-1T5G.rst diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index bf026f4b7e61be..4614026b0f6e44 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -1329,7 +1329,7 @@ Using the non-data descriptor protocol, a pure Python version of def __get__(self, obj, cls=None): if cls is None: cls = type(obj) - if hasattr(obj, '__get__'): + if hasattr(self.f, '__get__'): return self.f.__get__(cls) return MethodType(self.f, cls) @@ -1353,7 +1353,7 @@ Using the non-data descriptor protocol, a pure Python version of >>> t.cm(11, 22) (, 11, 22) -The code path for ``hasattr(obj, '__get__')`` was added in Python 3.9 and +The code path for ``hasattr(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: diff --git a/Misc/NEWS.d/next/Documentation/2021-04-22-23-18-26.bpo-bpo-43917.d-1T5G.rst b/Misc/NEWS.d/next/Documentation/2021-04-22-23-18-26.bpo-bpo-43917.d-1T5G.rst new file mode 100644 index 00000000000000..2f7d55c0c77181 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2021-04-22-23-18-26.bpo-bpo-43917.d-1T5G.rst @@ -0,0 +1 @@ +Fixed example python implementation of classmethod in the documentation of descriptor. \ No newline at end of file