Issue44904
Created on 2021-08-12 21:16 by rzepecki.t, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| bug_report.py | rzepecki.t, 2021-08-12 21:16 | Example of the issue | ||
| classmethod_properties_bug.py | AlexWaygood, 2021-08-15 15:13 | Short script demonstrating how a bug relating to classmethod properties causes doctest.py 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 https://stackoverflow.com/a/68763572/4434666 for details. |
|||
| msg399622 - (view) | Author: Alex Waygood (AlexWaygood) * ![]() |
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 doctest.py to crash with a fairly incomprehensible `AttributeError`:
Script:
class Untestable:
"""
>>> Untestable.my_classmethod_property
'Oh no!'
"""
@classmethod
@property
def my_classmethod_property(cls):
return 'Oh no!'
if __name__ == '__main__':
import doctest
doctest.testmod()
Output:
Traceback (most recent call last):
File "C:/Users/Alex/classmethod_properties_bug.py", line 13, in <module>
doctest.testmod()
File "C:\Users\Alex\.conda\envs\WebGame39\lib\doctest.py", line 1955, in testmod
for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
File "C:\Users\Alex\.conda\envs\WebGame39\lib\doctest.py", line 939, in find
self._find(tests, obj, name, module, source_lines, globs, {})
File "C:\Users\Alex\.conda\envs\WebGame39\lib\doctest.py", line 1001, in _find
self._find(tests, val, valname, module, source_lines,
File "C:\Users\Alex\.conda\envs\WebGame39\lib\doctest.py", line 1028, in _find
val = getattr(obj, valname).__func__
AttributeError: 'str' object has no attribute '__func__'
|
|||
| msg403612 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
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) * ![]() |
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) https://github.com/python/cpython/commit/b1302abcc8a4be5f39b4d60a1ce28032b77655b3 |
|||
| 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) https://github.com/python/cpython/commit/1f45cc0dfa9a8febfc256411c803b4536719db97 |
|||
| 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) https://github.com/python/cpython/commit/8365a5b5abe51cbe4151d89a5d0a993273320067 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:48 | admin | set | github: 89067 |
| 2021-10-28 08:13:53 | miss-islington | set | messages: + msg405157 |
| 2021-10-28 08:09:56 | miss-islington | set | messages: + msg405156 |
| 2021-10-28 07:48:28 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg405154 |
| 2021-10-28 07:48:22 | miss-islington | set | pull_requests: + pull_request27527 |
| 2021-10-28 07:48:17 | miss-islington | set | nosy:
+ miss-islington pull_requests: + pull_request27526 |
| 2021-10-10 22:18:34 | rhettinger | set | status: open -> closed superseder: Calling `help` executes @classmethod @property decorated methods nosy:
+ rhettinger |
| 2021-10-09 19:36:35 | AlexWaygood | set | nosy:
+ tim.peters title: Erroneous behaviour for abstract class properties -> Classmethod properties are erroneously "called" in multiple modules |
| 2021-10-09 18:17:17 | AlexWaygood | set | versions: + Python 3.10, Python 3.11 |
| 2021-10-09 18:15:55 | AlexWaygood | set | keywords:
+ patch stage: patch review pull_requests: + pull_request27153 |
| 2021-08-15 15:13:33 | AlexWaygood | set | files:
+ classmethod_properties_bug.py nosy: + AlexWaygood messages: + msg399622 |
| 2021-08-12 21:16:41 | rzepecki.t | create | |

