tiny edit, fix a couple of minor typos in enum and sqlite3 docs (GH-148580)
pair of minor doc typo fixes
(cherry picked from commit 236aa0a4e2)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
gh-137335: remove a mktemp use in multiprocessing.connection to avoid security scanner noise (GH-148578)
remove a mktemp use to avoid security scanner noise
(cherry picked from commit fd81246bd5)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
The Generator._make_boundary regex did not match on boundary phrases correctly when using CRLF line endings due to re.MULTILINE not considering \r\n as a line ending.
(cherry picked from commit 4af46b4ab5)
Co-authored-by: Henry Jones <44321887+henryivesjones@users.noreply.github.com>
Adds handling for a test case seen in the iOS SSL tests where an SSL connection fails to
handshake correctly.
(cherry picked from commit c40e8b016a)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
gh-146139: Disable `socketpair` authentication on WASI (GH-146140)
Calling `connect(2)` on a non-blocking socket on WASI may leave the socket in a
"connecting" but not yet "connected" state. In the former case, calling
`getpeername(2)` on it will fail, leading to an unhandled exception in Python.
(cherry picked from commit a5b76d53bb)
Co-authored-by: Joel Dice <joel.dice@akamai.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Brett Cannon <brett@python.org>
The watcher-bits read in _PyDict_NotifyEvent needs to use acquire to
synchronize with the release from PyDict_Watch so that the callback
publication is visible before the callback is invoked.
(cherry picked from commit 19f96f99fe)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-148395: Fix a possible UAF in `{LZMA,BZ2,_Zlib}Decompressor` (GH-148396)
Fix dangling input pointer after `MemoryError` in _lzma/_bz2/_ZlibDecompressor.decompress
(cherry picked from commit 8fc66aef6d)
Co-authored-by: Stan Ulbrych <stan@python.org>
Ensures that the testbed's Gradle configuration uses the cross-build environment
variable, and that variable is passed to Gradle by the cross-build script.
(cherry picked from commit b29afe62f7)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Co-authored-by: Malcolm Smith <smith@chaquo.com>
tests: use errno.EBADF instead of hardcoded number in _close_file() (GH-148345)
test_interpreters: use errno.EBADF instead of hardcoded number in _close_file()
Replace the hardcoded `9` check in `Lib/test/test_interpreters/utils.py` with `errno.EBADF`.
Using `errno.EBADF` makes the helper portable across platforms with different errno numbering while preserving the intended behavior.
(cherry picked from commit cef334fd4c)
Co-authored-by: Artem Yarulin <artem.yarulin@kapteko.com>
gh-146313: Fix multiprocessing ResourceTracker deadlock after os.fork() (GH-146316)
`ResourceTracker.__del__` (added in gh-88887 circa Python 3.12) calls
os.waitpid(pid, 0) which blocks indefinitely if a process created via os.fork()
still holds the tracker pipe's write end. The tracker never sees EOF, never
exits, and the parent hangs at interpreter shutdown.
Fix with two layers:
- **At-fork handler.** An os.register_at_fork(after_in_child=...)
handler closes the inherited pipe fd in the child unless a preserve
flag is set. popen_fork.Popen._launch() sets the flag before its
fork so mp.Process(fork) children keep the fd and reuse the parent's
tracker (preserving gh-80849). Raw os.fork() children close the fd,
letting the parent reap promptly.
- **Timeout safety-net.** _stop_locked() gains a wait_timeout
parameter. When called from `__del__`, it polls with WNOHANG using
exponential backoff for up to 1 second instead of blocking
indefinitely. The at-fork handler makes this unreachable in
well-behaved paths; it remains for abnormal shutdowns.
(cherry picked from commit 3a7df632c9)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Itamar Oren <itamarost@gmail.com>
Fixes data races between dict mutation and watch/unwatch on the same dict.
(cherry picked from commit 3ab94d6842)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-147965: Add shutdown() to multiprocessing.Queue excluded methods (GH-147970)
The multiprocessing.Queue documentation states it implements all
methods of queue.Queue except task_done() and join(). Since
queue.Queue.shutdown() was added in Python 3.13,
multiprocessing.Queue also does not implement it. Update the docs
to include shutdown() in the list of excluded methods.
(cherry picked from commit 22290ed011)
Co-authored-by: WYSIATI <chester.lee.cold@gmail.com>
gh-148337: Document `importlib.resources` security model (GH-148340)
(cherry picked from commit 70b86e7829)
Co-authored-by: Stan Ulbrych <stan@python.org>
gh-146333: Fix quadratic regex backtracking in configparser option parsing (GH-146399)
Use negative lookahead in option regex to prevent backtracking, and to avoid changing logic outside the regexes (since people could use the regex directly).
(cherry picked from commit 7e0a0be409)
Co-authored-by: Joshua Swanson <22283299+joshuaswanson@users.noreply.github.com>
gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106)
When a custom iterator calls next() on the same csv.reader from
within __next__, the inner iteration sets self->fields to NULL.
The outer iteration then crashes in parse_save_field() by passing
NULL to PyList_Append.
Add a guard after PyIter_Next() to detect that fields was set to
NULL by a re-entrant call, and raise csv.Error instead of crashing.
(cherry picked from commit 20994b1809)
Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
gh-148284: Block inlining of gigantic functions in ceval.c for clang 22 (GH-148334)
(cherry picked from commit e007631e99)
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-148274: properly handle result from `PyObject_VisitManagedDict` (GH-148275)
(cherry picked from commit ee2775cfae)
Co-authored-by: Max Bachmann <kontakt@maxbachmann.de>
Original patch by gigaplastik, extended with a few more tests.
Addresses gh-70039 and bpo-25852: failure of starttls if connect is called explicitly.
(cherry picked from commit 442f83a5ea)
Co-authored-by: nmartensen <nis.martensen@web.de>
Avoid embedding the parent's sys.argv into the forkserver -c command
string via repr(). When sys.argv is large (e.g. thousands of file
paths from a pre-commit hook), the resulting single argument could
exceed the OS per-argument length limit (MAX_ARG_STRLEN on Linux,
typically 128 KiB), causing posix_spawn to fail and the parent to
observe a BrokenPipeError.
Instead, append the argv entries as separate command-line arguments
after -c; the forkserver child reads them back as sys.argv[1:]. This
cannot exceed any limit the parent itself did not already satisfy.
Regression introduced by gh-143706 / 298d5440eb.
(cherry picked from commit 5e9d90b615)