Skip to content

gh-136438: Make sure test.test_pydoc.test_pydoc pass with all optimization levels - #136479

Merged
hauntsaninja merged 1 commit into
python:mainfrom
Grivvus:issue-136438-pydoc
Oct 12, 2025
Merged

gh-136438: Make sure test.test_pydoc.test_pydoc pass with all optimization levels#136479
hauntsaninja merged 1 commit into
python:mainfrom
Grivvus:issue-136438-pydoc

Conversation

@Grivvus

@GrivvusGrivvus commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Output before:

test test.test_pydoc.test_pydoc failed -- Traceback (most recent call last):
File "/home/grivvus/cpython/Lib/test/test_pydoc/test_pydoc.py", line 1464, in test_special_form
self.assertIn('NoReturn = class _SpecialForm(_Final)', doc)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'NoReturn = class _SpecialForm(_Final)' not found in 'Python Library Documentation: _SpecialForm in module typing object\n\nNoReturn = class _SpecialForm(_Final, _NotIterable)\n | NoReturn(getitem)\n |\n | # Internal indicator of special typing constructs.\n | # See __doc__ instance attribute for specific docs.\n |\n | Method resolution order:\n | _SpecialForm\n | _Final\n | _NotIterable\n | builtins.object\n |\n | Methods defined here:\n |\n | __call__(self, *args, **kwds)\n | Call self as a function.\n |\n | __getattr__(self, item)\n |\n | __getitem__(self, parameters)\n |\n | __init__(self, getitem)\n | Initialize self. See help(type(self)) for accurate signature.\n |\n | __instancecheck__(self, obj)\n | Check if an object is an instance.\n |\n | __mro_entries__(self, bases)\n |\n | __or__(self, other)\n | Return self|value.\n |\n | __reduce__(self)\n | Helper for pickle.\n |\n | __repr__(self)\n | Return repr(self).\n |\n | __ror__(self, other)\n | Return value|self.\n |\n | __subclasscheck__(self, cls)\n | Check if a class is a subclass.\n |\n | ----------------------------------------------------------------------\n | Class methods inherited from _Final:\n |\n | __init_subclass__(*args, **kwds)\n | This method is called when a class is subclassed.\n |\n | The default implementation does nothing. It may be\n | overridden to extend subclasses.\n |\n | ----------------------------------------------------------------------\n | Data descriptors inherited from _Final:\n |\n | __weakref__\n | list of weak references to the object\n |\n | ----------------------------------------------------------------------\n | Data and other attributes inherited from _NotIterable:\n |\n | __iter__ = None\n'
0:00:02 load avg: 0.60 [1/1/1] test.test_pydoc.test_pydoc failed (1 failure)
== Tests result: FAILURE ==

@python-cla-bot

python-cla-botBot commented Jul 9, 2025

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-appbedevere-appBot added the tests Tests in the Lib/test dir label Jul 9, 2025
@bedevere-appbedevere-appBot mentioned this pull request Jul 9, 2025
8 tasks
self.assertIn(typing.NoReturn.__doc__.strip().splitlines()[0], doc)
else:
self.assertIn('NoReturn = class _SpecialForm(_Final)', doc)
self.assertIn('NoReturn = class _SpecialForm(_Final, _NotIterable)', doc)

@StanFromIrelandStanFromIrelandJul 10, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter was added 3 years ago, and popped up now because -OO optimizes away typing.NoReturn.__doc__. I think we need a better solution here, since this is not properly tested.

cc @hauntsaninja who I see added this test

@hauntsaninjahauntsaninjaJul 10, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't add the test, I just fixed it up to accommodate another change. The test was added in #30253

Not sure that there's a good solution to be had really, maybe you have ideas! pydoc does depend on __doc__... if we want to guarantee tests pass on -OO we probably just have to run tests with -OO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, proposed fix is correct. There was a PR #92262 merged after last test change. For now, _SpecialForm inherits from _Final and _NotIterable, and pydoc reacts on this.

@efimov-mikhailefimov-mikhail left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hauntsaninja
hauntsaninja merged commit bb85af3 into python:mainOct 12, 2025
53 checks passed
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable Refleaks 3.x (tier-1) has failed when building commit bb85af3.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/320/builds/3138) and take a look at the build logs.
  4. Check if the failure is related to this commit (bb85af3) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/320/builds/3138

Failed tests:

  • test_pyrepl
  • test.test_multiprocessing_fork.test_processes

Failed subtests:

  • test_repl_eio - test.test_pyrepl.test_unix_console.TestUnixConsoleEIOHandling.test_repl_eio
  • test_interrupt - test.test_multiprocessing_fork.test_processes.WithProcessesTestProcess.test_interrupt

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/test_pyrepl/test_unix_console.py", line 376, in test_repl_eio
_, err = proc.communicate(timeout=support.LONG_TIMEOUT)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/subprocess.py", line 1219, in communicate
stdout, stderr =self._communicate(input, endtime, timeout)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/subprocess.py", line 2126, in _communicateself._check_timeout(endtime, orig_timeout, stdout, stderr)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/subprocess.py", line 1266, in _check_timeoutraise TimeoutExpired(
...<2 lines>...
stderr=b''.join(stderr_seq) if stderr_seq elseNone)
subprocess.TimeoutExpired: Command '['/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/python', '-E', '-S', '/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/test_pyrepl/eio_test_script.py']' timed out after 675.0 seconds
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/contextlib.py", line 85, in innerreturn func(*args, **kwds)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 596, in test_interrupt
exitcode =self._kill_process(multiprocessing.Process.interrupt)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/contextlib.py", line 85, in innerreturn func(*args, **kwds)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 577, in _kill_processself.assertEqual(join(), None)
~~~~^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 250, in __call__returnself.func(*args, **kwds)
~~~~~~~~~^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/process.py", line 156, in join
res =self._popen.wait(timeout)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/popen_fork.py", line 44, in waitreturnself.poll(os.WNOHANGif timeout ==0.0else0)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/popen_fork.py", line 28, in poll
pid, sts = os.waitpid(self.pid, flag)
~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 573, in handlerraiseRuntimeError('join took too long: %s'% p)
RuntimeError: join took too long: <Process name='Process-2' pid=2721947 parent=2721933 started daemon>
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/process.py", line 320, in _bootstrapself.run()
~~~~~~~~^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/process.py", line 108, in runself._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 524, in _sleep_some_event
time.sleep(100)
~~~~~~~~~~^^^^^
KeyboardInterrupt
k
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/subprocess.py", line 1137, in __del__
_warn("subprocess %s is still running"%self.pid,
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ResourceWarning, source=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ResourceWarning: subprocess 2668488 is still running
Warning -- Unraisable exception
Exception ignored while finalizing file <_io.FileIO name=8 mode='rb' closefd=True>:
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 165, in _load_run_test
regrtest_runner(result, test_func, runtests)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 114, in regrtest_runner
refleak, test_result = runtest_refleak(result.test_name, test_func,
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
runtests.hunt_refleak,
^^^^^^^^^^^^^^^^^^^^^^
runtests.quiet)
^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/refleak.py", line 145, in runtest_refleak
result = test_func()
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 162, in test_funcreturn run_unittest(test_mod, runtests)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 42, in run_unittestreturn _run_suite(tests)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 105, in _run_suiteraise support.TestFailedWithDetails(err, errors, failures, stats=stats)
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/support/__init__.py", line 847, in gc_collect
gc.collect()
~~~~~~~~~~^^ResourceWarning: unclosed file <_io.FileIO name=8 mode='rb' closefd=True>
Warning -- Unraisable exception
Exception ignored while finalizing file <_io.FileIO name=10 mode='rb' closefd=True>:
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 165, in _load_run_test
regrtest_runner(result, test_func, runtests)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 114, in regrtest_runner
refleak, test_result = runtest_refleak(result.test_name, test_func,
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
runtests.hunt_refleak,
^^^^^^^^^^^^^^^^^^^^^^
runtests.quiet)
^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/refleak.py", line 145, in runtest_refleak
result = test_func()
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 162, in test_funcreturn run_unittest(test_mod, runtests)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 42, in run_unittestreturn _run_suite(tests)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 105, in _run_suiteraise support.TestFailedWithDetails(err, errors, failures, stats=stats)
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/support/__init__.py", line 847, in gc_collect
gc.collect()
~~~~~~~~~~^^ResourceWarning: unclosed file <_io.FileIO name=10 mode='rb' closefd=True>
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 165, in _load_run_test
regrtest_runner(result, test_func, runtests)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 114, in regrtest_runner
refleak, test_result = runtest_refleak(result.test_name, test_func,
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
runtests.hunt_refleak,
^^^^^^^^^^^^^^^^^^^^^^
runtests.quiet)
^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/refleak.py", line 145, in runtest_refleak
result = test_func()
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 162, in test_funcreturn run_unittest(test_mod, runtests)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 42, in run_unittestreturn _run_suite(tests)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/libregrtest/single.py", line 105, in _run_suiteraise support.TestFailedWithDetails(err, errors, failures, stats=stats)
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/contextlib.py", line 85, in innerreturn func(*args, **kwds)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 596, in test_interrupt
exitcode =self._kill_process(multiprocessing.Process.interrupt)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/contextlib.py", line 85, in innerreturn func(*args, **kwds)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 577, in _kill_processself.assertEqual(join(), None)
~~~~^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 250, in __call__returnself.func(*args, **kwds)
~~~~~~~~~^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/process.py", line 156, in join
res =self._popen.wait(timeout)
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/popen_fork.py", line 44, in waitreturnself.poll(os.WNOHANGif timeout ==0.0else0)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/popen_fork.py", line 28, in poll
pid, sts = os.waitpid(self.pid, flag)
~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 573, in handlerraiseRuntimeError('join took too long: %s'% p)
RuntimeError: join took too long: <Process name='Process-147' pid=2620893 parent=2616818 started daemon>

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@Grivvus@bedevere-bot@efimov-mikhail@hauntsaninja@StanFromIreland