Closed
Description
Bug report
The doctest
module fails when an object of type method-wrapper
is globally declared, but this only occurs with Python 3.11.0 and works with Python 3.10.3, as shown by the example.
$ read -r -d '' code << EOM
import doctest
if __name__ == '__main__':
_ = object.__getattribute__.__get__(object())
doctest.testmod(verbose=True)
EOM
$ python3.10 -c "$code"
1 items had no tests:
__main__
0 tests in 1 items.
0 passed and 0 failed.
Test passed.
$ python3.11 -c "$code"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Lib/doctest.py", line 1970, in testmod
for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Lib/doctest.py", line 940, in find
self._find(tests, obj, name, module, source_lines, globs, {})
File "/Lib/doctest.py", line 1013, in _find
self._from_module(module, val)):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Lib/doctest.py", line 975, in _from_module
raise ValueError("object must be a class or function")
ValueError: object must be a class or function
Environment
- CPython versions tested on: 3.10.3 and 3.11.0 (compiled from sources with GCC 7.5.0)
- Operating System: openSUSE Leap 15.2 x86_64
- Kernel: 5.3.18-lp152.106-default