cpython/Misc
Miss Islington (bot) 61a24ea572
[3.13] gh-137109: refactor warning about threads when forking (GH-141438) (GH-141614) (GH-141639)
[3.14] gh-137109: refactor warning about threads when forking (GH-141438) (GH-141614)

This splits the OS API specific functionality to get the number of threads out
from the fallback Python method and warning raising code itself.  This way the
OS APIs can be queried before we've run
`os.register_at_fork(after_in_parent=...)` registered functions which
themselves may (re)start threads that would otherwise be detected.

This is best effort.  If the OS APIs are either unavailable or fail, the
warning generating code still falls back to looking at the Python threading
state after the CPython interpreter world has been restarted and the
after_in_parent calls have been made.  The common case for most Linux and macOS
environments should work today.

This also lines up with the existing TODO refactoring, we may choose to expose
this API to get the number of OS threads in the `os` module in the future.

Note: This is a simplified backport that maintains the void return type
for warn_about_fork_with_threads() and keeps PyErr_Clear() in the warning path,
as the error handling changes from fd8f42d3d1 are not needed in 3.14.
(cherry picked from commit 0d8fb0b852)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2025-11-16 19:26:34 -08:00
..
mypy [3.13] gh-133117: Run mypy on tomllib in CI (GH-133118) (#133192) 2025-04-30 12:57:57 +00:00
NEWS.d [3.13] gh-137109: refactor warning about threads when forking (GH-141438) (GH-141614) (GH-141639) 2025-11-16 19:26:34 -08:00
rhel7 gh-95957: Add instructions for Tcl/Tk and OpenSSL on RHEL/CentOS 7 (#95964) 2022-08-16 13:44:02 +02:00
ACKS [3.13] gh-134759: fix UnboundLocalError in email.message.Message.get_payload (GH-136071) (#136580) 2025-07-12 13:52:54 +00:00
coverity_model.c [3.13] Fix typos (#123775) (#123866) 2024-10-07 23:44:31 +02:00
externals.spdx.json [3.13] gh-139573: Update Windows builds to use OpenSSL 3.0.18 (GH-139587) 2025-10-04 20:53:16 -05:00
HISTORY [3.13] gh-123492: Remove unnecessary :func: parentheses (gh-123493) (#123513) 2024-08-30 20:14:48 +03:00
indent.pro
platform_triplet.c [3.13] gh-132026: Ensure _MIPS_SIM has defined _ABI identifiers for comparison (GH-133092) 2025-04-28 12:15:45 -05:00
Porting
python-config.in bpo-45101: Add consistency in usage message IO between 2 versions of python-config (GH-28162) 2024-02-26 22:04:44 +02:00
python-config.sh.in [3.13] gh-116622: Rename build variable MODULE_LDFLAGS back to LIBPYTHON (GH-122764) (GH-122842) 2024-08-09 14:45:04 -07:00
python-embed.pc.in
python.man [3.13] Manpage: -X gil is not related to PYTHON_HISTORY (GH-133753) (#133759) 2025-05-09 14:18:56 +00:00
python.pc.in [3.13] gh-116622: Rename build variable MODULE_LDFLAGS back to LIBPYTHON (GH-122764) (GH-122842) 2024-08-09 14:45:04 -07:00
README gh-102809: Remove gdbinit mention in Misc/README (#103269) 2023-04-08 00:04:23 -07:00
README.AIX
README.coverity
README.valgrind closes docs: remove references to Py_USING_MEMORY_DEBUGGER (GH-30284) 2021-12-29 16:20:42 -06:00
sbom.spdx.json [3.13] gh-139312: Update bundled libexpat to 2.7.3 (GH-139319) (#139377) 2025-09-27 08:19:09 +00:00
SpecialBuilds.txt gh-108634: Py_TRACE_REFS uses a hash table (#108663) 2023-08-31 18:33:34 +02:00
stable_abi.toml [3.13] gh-138189: Document type slots, and other constants, as part of Limited API (GH-138190) (GH-141193) 2025-11-13 13:28:57 +01:00
svnmap.txt
valgrind-python.supp [3.13] gh-121096: Ignore dlopen() leaks in Valgrind suppression file (GH-121097) (#121122) 2024-06-28 11:26:37 +00:00
vgrindefs

Python Misc subdirectory
========================

This directory contains files that wouldn't fit in elsewhere.  Some
documents are only of historic importance.

Files found here
----------------

ACKS                    Acknowledgements
HISTORY                 News from previous releases -- oldest last
indent.pro              GNU indent profile approximating my C style
NEWS                    News for this release (for some meaning of "this")
Porting                 Mini-FAQ on porting to new platforms
python-config.in        Python script template for python-config
python.man              UNIX man page for the python interpreter
python.pc.in            Package configuration info template for pkg-config
README                  The file you're reading now
README.AIX              Information about using Python on AIX
README.coverity         Information about running Coverity's Prevent on Python
README.valgrind         Information for Valgrind users, see valgrind-python.supp
SpecialBuilds.txt       Describes extra symbols you can set for debug builds
svnmap.txt              Map of old SVN revs and branches to hg changeset ids,
                        help history-digging
valgrind-python.supp    Valgrind suppression file, see README.valgrind
vgrindefs               Python configuration for vgrind (a generic pretty printer)