Skip to content
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

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

Closed
picnixz opened this issue Nov 13, 2022 · 0 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@picnixz
Copy link
Contributor

picnixz commented Nov 13, 2022

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
@picnixz picnixz added the type-bug An unexpected behavior, bug, or error label Nov 13, 2022
@AlexWaygood AlexWaygood added the stdlib Python modules in the Lib dir label Nov 13, 2022
sobolevn added a commit to sobolevn/cpython that referenced this issue Nov 13, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 30, 2022
…ythonGH-99434)

(cherry picked from commit 79c10b7)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
miss-islington added a commit that referenced this issue Dec 30, 2022
(cherry picked from commit 79c10b7)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants