This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Classmethod properties are erroneously "called" in multiple modules
Type: behavior Stage: resolved
Components: Versions: Python 3.11, Python 3.10, Python 3.9
Status: closed Resolution: duplicate
Dependencies: Superseder: Calling `help` executes @classmethod @property decorated methods
View: 45356
Assigned To: Nosy List: AlexWaygood, miss-islington, rhettinger, rzepecki.t, serhiy.storchaka, tim.peters
Priority: normal Keywords: patch

Created on 2021-08-12 21:16 by rzepecki.t, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit rzepecki.t, 2021-08-12 21:16 Example of the issue AlexWaygood, 2021-08-15 15:13 Short script demonstrating how a bug relating to classmethod properties causes to crash
Pull Requests
URL Status Linked Edit
PR 28838 merged AlexWaygood, 2021-10-09 18:15
PR 29261 merged miss-islington, 2021-10-28 07:48
PR 29262 merged miss-islington, 2021-10-28 07:48
Messages (6)
msg399482 - (view) Author: Tomasz Rzepecki (rzepecki.t) Date: 2021-08-12 21:16
Subclassing an abc with an abstract class property yields to unexpected behaviour: the class property is called, and an abstract class may be erroneously considered concrete.

See for details.
msg399622 - (view) Author: Alex Waygood (AlexWaygood) * (Python triager) Date: 2021-08-15 15:13
This same bug (where classmethod properties are accidentally called by other parts of Python) is also present for non-abstract class properties, and has the side effect of causing to crash with a fairly incomprehensible `AttributeError`:


    class Untestable:
        >>> Untestable.my_classmethod_property
        'Oh no!'

        def my_classmethod_property(cls):
            return 'Oh no!'

    if __name__ == '__main__':
        import doctest


    Traceback (most recent call last):
      File "C:/Users/Alex/", line 13, in <module>
      File "C:\Users\Alex\.conda\envs\WebGame39\lib\", line 1955, in testmod
        for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
      File "C:\Users\Alex\.conda\envs\WebGame39\lib\", line 939, in find
        self._find(tests, obj, name, module, source_lines, globs, {})
      File "C:\Users\Alex\.conda\envs\WebGame39\lib\", line 1001, in _find
        self._find(tests, val, valname, module, source_lines,
      File "C:\Users\Alex\.conda\envs\WebGame39\lib\", line 1028, in _find
        val = getattr(obj, valname).__func__
    AttributeError: 'str' object has no attribute '__func__'
msg403612 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-10-10 22:18
Moving this discussion to issue 45356 because some of the discussion would need to be duplicated.
msg405154 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-10-28 07:48
New changeset b1302abcc8a4be5f39b4d60a1ce28032b77655b3 by Alex Waygood in branch 'main':
bpo-44904: Fix classmethod property bug in doctest module (GH-28838)
msg405156 - (view) Author: miss-islington (miss-islington) Date: 2021-10-28 08:09
New changeset 1f45cc0dfa9a8febfc256411c803b4536719db97 by Miss Islington (bot) in branch '3.10':
bpo-44904: Fix classmethod property bug in doctest module (GH-28838)
msg405157 - (view) Author: miss-islington (miss-islington) Date: 2021-10-28 08:13
New changeset 8365a5b5abe51cbe4151d89a5d0a993273320067 by Miss Islington (bot) in branch '3.9':
bpo-44904: Fix classmethod property bug in doctest module (GH-28838)
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 89067
2021-10-28 08:13:53miss-islingtonsetmessages: + msg405157
2021-10-28 08:09:56miss-islingtonsetmessages: + msg405156
2021-10-28 07:48:28serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg405154
2021-10-28 07:48:22miss-islingtonsetpull_requests: + pull_request27527
2021-10-28 07:48:17miss-islingtonsetnosy: + miss-islington

pull_requests: + pull_request27526
2021-10-10 22:18:34rhettingersetstatus: open -> closed

superseder: Calling `help` executes @classmethod @property decorated methods

nosy: + rhettinger
messages: + msg403612
resolution: duplicate
stage: patch review -> resolved
2021-10-09 19:36:35AlexWaygoodsetnosy: + tim.peters

title: Erroneous behaviour for abstract class properties -> Classmethod properties are erroneously "called" in multiple modules
2021-10-09 18:17:17AlexWaygoodsetversions: + Python 3.10, Python 3.11
2021-10-09 18:15:55AlexWaygoodsetkeywords: + patch
stage: patch review
pull_requests: + pull_request27153
2021-08-15 15:13:33AlexWaygoodsetfiles: +
nosy: + AlexWaygood
messages: + msg399622

2021-08-12 21:16:41rzepecki.tcreate