Skip to content

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

@picnixz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy