-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classmethod properties are erroneously "called" in multiple modules #89067
Comments
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. |
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 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__' |
Moving this discussion to bpo-45356 because some of the discussion would need to be duplicated. |
This is not fixed, you just fixed an issue on doctest module but the issue persist if you create an abstract class property |
help
executes @classmethod @Property decorated methodsNote: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: