Message399622
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__' |
|
Date |
User |
Action |
Args |
2021-08-15 15:13:34 | AlexWaygood | set | recipients:
+ AlexWaygood, rzepecki.t |
2021-08-15 15:13:33 | AlexWaygood | set | messageid: <1629040413.99.0.951748156759.issue44904@roundup.psfhosted.org> |
2021-08-15 15:13:33 | AlexWaygood | link | issue44904 messages |
2021-08-15 15:13:33 | AlexWaygood | create | |
|