gh-135427: Fix DeprecationWarning for os.fork when run in threads with -Werror (GH-136796)

Don't ignore errors raised by `PyErr_WarnFormat` in `warn_about_fork_with_threads`
Instead, ignore the warnings in all test code that forks. (That's a lot of functions.)

In `test_support`, make `ignore_warnings` a context manager (as well as decorator),
and add a `message` argument to it.
Also add a `ignore_fork_in_thread_deprecation_warnings` helper for the deadlock-in-fork
warning.
This commit is contained in:
Rani Pinchuk 2025-08-26 15:33:21 +02:00 committed by GitHub
parent f60f8225ed
commit fd8f42d3d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 390 additions and 69 deletions

View file

@ -8,7 +8,7 @@
from test.support.script_helper import (assert_python_ok, assert_python_failure,
interpreter_requires_environment)
from test import support
from test.support import force_not_colorized
from test.support import force_not_colorized, warnings_helper
from test.support import os_helper
from test.support import threading_helper
@ -354,6 +354,7 @@ def fork_child(self):
# everything is fine
return 0
@warnings_helper.ignore_fork_in_thread_deprecation_warnings()
@support.requires_fork()
def test_fork(self):
# check that tracemalloc is still working after fork