You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Classmethod properties are erroneously "called" in multiple modules #89067
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.
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:
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__'
changed the title [-]Erroneous behaviour for abstract class properties[/-][+]Classmethod properties are erroneously "called" in multiple modules[/+]on Oct 9, 2021
Activity
rzepeckit commentedon Aug 12, 2021
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.
AlexWaygood commentedon Aug 15, 2021
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:
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__'[-]Erroneous behaviour for abstract class properties[/-][+]Classmethod properties are erroneously "called" in multiple modules[/+]rhettinger commentedon Oct 10, 2021
Moving this discussion to bpo-45356 because some of the discussion would need to be duplicated.
serhiy-storchaka commentedon Oct 28, 2021
New changeset b1302ab by Alex Waygood in branch 'main':
bpo-44904: Fix classmethod property bug in doctest module (GH-28838)
b1302ab
miss-islington commentedon Oct 28, 2021
New changeset 1f45cc0 by Miss Islington (bot) in branch '3.10':
bpo-44904: Fix classmethod property bug in doctest module (GH-28838)
1f45cc0
miss-islington commentedon Oct 28, 2021
New changeset 8365a5b by Miss Islington (bot) in branch '3.9':
bpo-44904: Fix classmethod property bug in doctest module (GH-28838)
8365a5b
SharpEdgeMarshall commentedon Aug 29, 2022
This is not fixed, you just fixed an issue on doctest module but the issue persist if you create an abstract class property