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 <<EOMimport 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
fortestin 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)
Bug report
The
doctest
module fails when an object of typemethod-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.Environment
doctest
failure onMethodWrapperType
#99434doctest
failure ontypes.MethodWrapperType
(GH-99434) #100620The text was updated successfully, but these errors were encountered: