* Support non-UTF-8 shebang and comments if non-UTF-8 encoding is specified.
* Detect decoding error in comments for UTF-8 encoding.
* Include the decoding error position for default encoding in SyntaxError.
(cherry picked from commit 5c942f11cd)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.14] gh-140067: Fix memory leak in sub-interpreter creation (GH-140111)
Fix memory leak in sub-interpreter creation caused by overwriting of the previously used `_malloced` field. Now the pointer is stored in the first word of the memory block to avoid it being overwritten accidentally.
(cherry picked from commit 59547a251f)
Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
gh-140257: fix data race on eval_breaker during finalization (GH-140265)
(cherry picked from commit c8729c9909)
Co-authored-by: Shamil <ashm.tech@proton.me>
GH-133789: Fix unpickling of pathlib objects pickled in Python 3.13 (GH-133831)
In Python 3.13 (but not 3.12 or 3.14), pathlib classes are defined in
`pathlib._local` rather than `pathlib`. In hindsight this was a mistake,
but it was difficult to predict how the abstract/local split would pan out.
In this patch we re-introduce `pathlib._local` as a stub module that
re-exports the classes from `pathlib`. This allows path objects pickled in
3.13 to be unpicked in 3.14+
(cherry picked from commit f4e51f253a)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
gh-131788: make resource_tracker re-entrant safe (GH-131787)
* make resource_tracker re-entrant safe
* Update Lib/multiprocessing/resource_tracker.py
* trim trailing whitespace
* use f-string and args = [x, *y, z]
* raise self._reentrant_call_error
---------
(cherry picked from commit f24a012350)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
gh-140120: Refresh HACL* to fix an hmac memory leak (GH-140188)
This pulls an updated version of HACL* that fixes the memory leak reported in GH-140120, via an upstream fix.
(cherry picked from commit 3a81313019)
Co-authored-by: Jonathan Protzenko <jonathan.protzenko+github@gmail.com>
gh-138859: Account for `ParamSpec` defaults that are not lists … (GH-138868)
(cherry picked from commit 379fd020a0)
Co-authored-by: bzoracler <50305397+bzoracler@users.noreply.github.com>
Use sysconfig to determine the full name of libpython, rather than hardcoding
a library name that doesn't have ABI flags.
(cherry picked from commit 7f371ed84b)
Co-authored-by: Malcolm Smith <smith@chaquo.com>
gh-140153: Fix Py_REFCNT() definition on limited C API 3.11-3.13 (GH-140158)
(cherry picked from commit 728d239e57)
Co-authored-by: Victor Stinner <vstinner@python.org>
The previous `Py_REFCNT(x) == 1` checks can have data races in the free
threaded build. `_PyObject_IsUniquelyReferenced(x)` is a more conservative
check that is safe in the free threaded build and is identical to
`Py_REFCNT(x) == 1` in the default GIL-enabled build.
(cherry picked from commit 32c264982e)
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Revert GH-131993.
Fix swallowing some syntax warnings in different modules if they accidentally
have the same message and are emitted from the same line.
Fix duplicated warnings in the "finally" block.
(cherry picked from commit 279db6bede)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Update 2025-10-06-10-03-37.gh-issue-139640.gY5oTb.rst
---------
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.14] gh-102431: Clarify constraints on operands of Decimal logical operations (GH-102836)
Sync C/Python implementation of the decimal: logical_ops for contexts.
(cherry picked from commit 6ecf77dbde)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
gh-70765: Remove unnecessary extra backtick from Changelog entry (GH-140071)
(cherry picked from commit f70082b477)
Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>
gh-139988: fix a leak when failing to create a Union type (GH-139990)
(cherry picked from commit 6710156bd2)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-139905: Provide suggestion in error message if `Generic.__init_subclass__` was not called (GH-139943)
(cherry picked from commit 5776d0d2e0)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
gh-96491: Deduplicate version in IDLE shell title (GH-139841)
Saving to a file added both the filename and repeated the version.
---------
(cherry picked from commit d4e5802588)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Don't cache the joined path in `_raw_path` because the caching isn't thread safe.
(cherry picked from commit d9b4eef71e)
Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.14] gh-139894: fix incorrect sharing of current task while forking in `asyncio` (GH-139897)
Fix incorrect sharing of current task with the forked child process by clearing thread state's current task and current loop in `PyOS_AfterFork_Child`.
(cherry picked from commit b881df47ff)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* Update Lib/test/test_asyncio/test_unix_events.py
Fix trailing space before a wrapped long word if the line length with
a space is exactly "width".
(cherry picked from commit 1c598e0436)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-139391: properly handle `signal.signal()` in `UnixConsole` when called from a non-main thread (GH-139392)
(cherry picked from commit b8c8b8f1d3)
Co-authored-by: yihong <zouzou0208@gmail.com>
gh-139742: Add support for Python 3.14 t-string prefixes in IDLE colorizer and tests (GH-139756)
Add 't' prefix to colorizer.py stringprefix regex to support Python 3.14 template strings.
Add t prefixes to test_colorizer.py source test text and adjust line numbers on test methods.
---------
(cherry picked from commit 6fd1418341)
Co-authored-by: Anuradha Agrawal <paysur2111@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
* [3.14] gh-139748: fix leaks in AC error paths when using unicode FS-based converters (GH-139765)
(cherry picked from commit b04a57deef)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-83424: Allow empty name if handle is non-null when create ctypes.CDLL on Windows (GH-136878)
(cherry picked from commit ed522ed211)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-137317: Fix inspect.signature() for class with wrapped __init__ or __new__ (GH-137862)
Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptor
that returns a wrapped function.
(cherry picked from commit 025a2135ef)
Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
It should interpret the result of wcsxfrm() as a sequence of abstract
integers, not a sequence of Unicode code points or using other encoding
scheme that does not preserve ordering.
(cherry picked from commit 482fd0c811)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Handle ECANCELED in the same way as EINTR to work around the Posix
violation in the NetBSD's implementation.
(cherry picked from commit 07d0b95b05)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Both modules should use the Python implementation in that case.
(cherry picked from commit 6620ef0ff6)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Don't fail trying to parse weird patterns.
* Don't fail trying to decode non-UTF-8 "robots.txt" files.
* No longer ignore trailing "?" in patterns and URLs.
* Distinguish raw special characters "?", "=" and "&" from the
percent-encoded ones.
* Remove tests that do nothing.
(cherry picked from commit cb7ef18d70)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
fix potential hang.
It can happen that the child crashes right in the beginning for whatever reason. In this case, the parent will hang when writing into the pipe, because the child fd is not closed yet.
The normal pattern is to close the child fds right after the child proc is forked/executed/spawned, so when the child dies, then also the pipes will be closed, and there will be no hang (the parent gets SIGPIPE instead).
(cherry picked from commit 8ed5a2b56c)
Co-authored-by: Albert Zeyer <albzey@gmail.com>
The OpenSSL and HACL* implementations of HMAC single-shot
digest computation reject keys whose length exceeds `INT_MAX`
and `UINT32_MAX` respectively. The OpenSSL implementation
also rejects messages whose length exceed `INT_MAX`.
Using such keys in `hmac.digest` previously raised an `OverflowError`
which was propagated to the caller. This commit mitigates this case by
making `hmac.digest` fall back to HMAC's pure Python implementation
which accepts arbitrary large keys or messages.
This change only affects the top-level entrypoint `hmac.digest`, leaving
`_hashopenssl.hmac_digest` and `_hmac.compute_digest` untouched.
(cherry picked from commit d658b9053b)