Skip to content

doctest fails with <method-wrapper> object on Python 3.11.0 but succeeds on Python 3.10.3 #99433

Closed

Description

@picnixz

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

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 13, 2022
  2. added a commit that references this issue on Nov 13, 2022
  3. added a commit that references this issue on Dec 30, 2022
  4. added a commit that references this issue on Dec 30, 2022
  5. added a commit that references this issue on Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions