Skip to content

test_typing shows DeprecationWarnings on 3.11 #115570

@JelleZijlstra

Description

@JelleZijlstra

Bug report

Bug description:

$ ./python -Werr -m test test_typing
Using random seed: 3326887933
0:00:00 load avg: 0.12 Run 1 test sequentially
0:00:00 load avg: 0.12 [1/1] test_typing
Failed to call load_tests:
Traceback (most recent call last):
  File "/home/jelle/cpython/Lib/unittest/loader.py", line 138, in loadTestsFromModule
    return load_tests(self, tests, pattern)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jelle/cpython/Lib/test/test_typing.py", line 8567, in load_tests
    tests.addTests(doctest.DocTestSuite(typing))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jelle/cpython/Lib/doctest.py", line 2419, in DocTestSuite
    tests = test_finder.find(module, globs=globs, extraglobs=extraglobs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jelle/cpython/Lib/doctest.py", line 942, in find
    self._find(tests, obj, name, module, source_lines, globs, {})
  File "/home/jelle/cpython/Lib/doctest.py", line 1016, in _find
    self._find(tests, val, valname, module, source_lines,
  File "/home/jelle/cpython/Lib/doctest.py", line 1004, in _find
    test = self._get_test(obj, name, module, globs, source_lines)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jelle/cpython/Lib/doctest.py", line 1062, in _get_test
    if obj.__doc__ is None:
       ^^^^^^^^^^^
  File "/home/jelle/cpython/Lib/typing.py", line 3386, in __getattribute__
    warnings.warn(
DeprecationWarning: typing.io is deprecated, import directly from typing instead. typing.io will be removed in Python 3.12.

test test_typing crashed -- Traceback (most recent call last):
  File "/home/jelle/cpython/Lib/test/libregrtest/single.py", line 178, in _runtest_env_changed_exc
    _load_run_test(result, runtests)
  File "/home/jelle/cpython/Lib/test/libregrtest/single.py", line 135, in _load_run_test
    regrtest_runner(result, test_func, runtests)
  File "/home/jelle/cpython/Lib/test/libregrtest/single.py", line 88, in regrtest_runner
    test_result = test_func()
                  ^^^^^^^^^^^
  File "/home/jelle/cpython/Lib/test/libregrtest/single.py", line 132, in test_func
    return run_unittest(test_mod)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jelle/cpython/Lib/test/libregrtest/single.py", line 35, in run_unittest
    raise Exception("errors while loading tests")
Exception: errors while loading tests

test_typing failed (uncaught exception)

== Tests result: FAILURE ==

1 test failed:
    test_typing

Total duration: 256 ms
Total tests: run=0
Total test files: run=1/1 failed=1
Result: FAILURE
$ ./python -V
Python 3.11.8+

We should probably allow access to __doc__ on the deprecated typing.io and typing.re pseudo-modules. I'll send a PR.

CPython versions tested on:

3.11

Operating systems tested on:

Linux, macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixestopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions