[3.14] gh-130167: Add a What's New entry for changes to ``textwrap.{de,in}dent`` (GH-131924) (#143292)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
[3.14] gh-69686: Remove untrue part of `__import__` replacement docs (GH-143261) (#143281)
gh-69686: Remove untrue part of `__import__` replacement docs (GH-143261)
Remove untrue part of `__import__` replacement docs
The original statement effectively says that replacing `__import__` at global scope affects import statements, and not only that, but only import statements within the rest of the executing module. None of that has been true since at least Python 2.7, I think.
[3.14] gh-143200: fix UAFs in `Element.__{set,get}item__` when the element is concurrently mutated (GH-143226) (#143273)
gh-143200: fix UAFs in `Element.__{set,get}item__` when the element is concurrently mutated (GH-143226)
(cherry picked from commit b6b0e14b3d4aa9e9b89bef9a516177238883e1a7)
[3.14] gh-142994, gh-142996: document missing async generator and coroutine field entries in `inspect` (GH-142997) (#143258)
gh-142994, gh-142996: document missing async generator and coroutine field entries in `inspect` (GH-142997)
(cherry picked from commit 0efbad60e13cbc8b27a5ca3a5d9afcdcc957b19e)
Changed condition to evaluate if timeout is less than or equals to 0. This is needed for simulated time environments such as Shadow where the time will match exactly on the boundary.
[3.14] gh-142557: fix UAF in `bytearray.__mod__` when object is mutated while formatting `%`-style arguments (GH-143213) (#143227)
gh-142557: fix UAF in `bytearray.__mod__` when object is mutated while formatting `%`-style arguments (GH-143213)
(cherry picked from commit 61ee04834b096be00678c6819b4957f3f4413a5e)
[3.14] gh-143195: fix UAF in `{bytearray,memoryview}.hex(sep)` via re-entrant `sep.__len__` (GH-143209) (#143219)
gh-143195: fix UAF in `{bytearray,memoryview}.hex(sep)` via re-entrant `sep.__len__` (GH-143209)
(cherry picked from commit 9976c2b6349a079ae39931d960b8c147e21c6c3f)
[3.14] gh-142975: During GC, mark frozen objects with a merged zero refcount for destruction (GH-143156) (GH-143175)
gh-142975: During GC, mark frozen objects with a merged zero refcount for destruction (GH-143156)
(cherry picked from commit 8611f74e089d9ac9de84dd42be9d251db27889aa)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
[3.14] gh-143004: Fix possible use-after-free in collections.Counter.update() (GH-143044) (GH-143166)
This happened when the Counter was mutated when incrementing
the value for an existing key.
(cherry picked from commit 86d904588e8c84c7fccb8faf84b343f03461970d)
[3.14] Correctly fold unknown-8bit originating from encoded words. (GH-142517) (#143146)
The unknown-8bit trick was designed to deal with unknown bytes in an
ASCII message, and it works fine for that. However, I also tried to
extend it to handle bytes that can't be decoded using the charset
specified in an encoded word, and there it fails because there can be
other non-ASCII characters that were *successfully* decoded. The fix is
simple: do the unknown-8bit encoding using the utf-8 codec. This is
especially appropriate since anyone trying to do recovery on an unknown
byte string will probably attempt utf-8 first.
(cherry picked from commit 1e17ccd030a2285ad53db5952360fffa33a8a877)
Co-authored-by: R. David Murray <rdmurray@bitdance.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
[3.14] gh-142145: Avoid timing measurements in quadratic behavior test (gh-143105) (#143139)
Count the number of Element attribute accesses as a proxy for work done.
With double the amount of work, a ratio of 2.0 indicates linear scaling
and 4.0 quadratic scaling. Use 3.2 as an intermediate threshold.
(cherry picked from commit 57937a8e5e293f0dcba5115f7b7a11b1e0c9a273)
[3.14] gh-109263: Start process from spawn context in multiprocessing no longer have side effect (GH-135813) (#143115)
gh-109263: Start process from spawn context in multiprocessing no longer have side effect (GH-135813)
(cherry picked from commit c2202a7e661d40b1837cc0109cdb9ab40ec4e486)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
[3.14] gh-143010: Prevent a TOCTOU issue by only calling open once (GH-143011) (#143080)
gh-143010: Prevent a TOCTOU issue by only calling open once (GH-143011)
RDM: per AZero13's research the 'x' option did not exist when this code was written, This
modernization can thus drop the fd trick in _create_carefully and just use open with 'x' to achieve the same goal more securely.
(cherry picked from commit a88d1b8dab4cbd3180dd7f1acb44d627db90323b)
[3.14] gh-70647: Better promote how to safely parse yearless dates in datetime. (GH-116179) (#143037)
gh-70647: Better promote how to safely parse yearless dates in datetime. (GH-116179)
* gh-70647: Better promote how to safely parse yearless dates in datetime.
Every four years people encounter this because it just isn't obvious.
This moves the footnote up to a note with a code example.
We'd love to change the default year value for datetime but doing
that could have other consequences for existing code. This documented
workaround *always* works.
* doctest code within note is bad, dedent.
* Update to match the error message.
* remove no longer referenced footnote
* ignore the warning in the doctest
* use Petr's suggestion for the docs to hide the warning processing
[3.14] gh-142754: Ensure that Element & Attr instances have the ownerDocument attribute (GH-142794) (#142818)
gh-142754: Ensure that Element & Attr instances have the ownerDocument attribute (GH-142794)
(cherry picked from commit 1cc7551b3f9f71efbc88d96dce90f82de98b2454)
Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
[3.14] gh-142560: prevent use-after-free in search-like methods by exporting buffer in bytearray (GH-142938) (#142983)
gh-142560: prevent use-after-free in search-like methods by exporting buffer in bytearray (GH-142938)
(cherry picked from commit 220f0b107776391201a399c54dd01692c36fcdf4)
[3.14] gh-142527: Docs: Clarify that random.seed() discards the sign of an integer input (GH-142483) (#142970)
gh-142527: Docs: Clarify that random.seed() discards the sign of an integer input (GH-142483)
If *a* is an integer, the sign of *a* is discarded in the C source code. Clarify this behavior to prevent foot guns, where a common use case might naively assume that flipping the sign will produce different sequences (e.g. for a train/test split of a synthetic data generator in machine learning).
(cherry picked from commit 610aabfef2f90dc1a274703779615aa5b7fbbb3a)
Co-authored-by: Andrej <andrej.karpathy@gmail.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
[3.14] gh-142873: Do not check for `PyContextVar_CheckExact` twice in `PyContextVar_Set` (GH-142874) (#142893)
gh-142873: Do not check for `PyContextVar_CheckExact` twice in `PyContextVar_Set` (GH-142874)
(cherry picked from commit e61a447d0e0753621e8fc347e99dfc87884d68ab)
[3.14] gh-142876: remove reference to thread in documentation of `asyncio.Queue.shutdown` (GH-142888) (#142891)
gh-142876: remove reference to thread in documentation of `asyncio.Queue.shutdown` (GH-142888)
(cherry picked from commit 77c8e6a2b8e206ea8151ab1b431e32f1cad51ddd)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
[3.14] gh-85222: Document the global start method side effect in multiprocessing (GH-136426) (#142770)
gh-85222: Document the global start method side effect in multiprocessing (GH-136426)
* Document the ctx parameter in some types in multiprocessing.
* Reduce duplication while still linking to the central explanation from API points with the side effect.
(cherry picked from commit 0978b9a7d5eedab19d7d39bd703ed5b55fd7aa5f)
Co-authored-by: AN Long <aisk@users.noreply.github.com> Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: R Chintan Meher <meherrihaan@gmail.com>
[3.14] gh-141938: document treatment of `OSError` raised by `HTTPConnection.getresponse` (GH-142339) (#142704)
gh-141938: document treatment of `OSError` raised by `HTTPConnection.getresponse` (GH-142339)
(cherry picked from commit 11aef219f5186fcb9b8121651e5bdbd7e84c3a4e)
[3.14] Add 'Show translation source' to docs sidebar (GH-130355) (#142686)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
If there are many untracked tuples, the GC will run too often, resulting
in poor performance. The fix is to include untracked tuples in the
"long lived" object count. The number of frozen objects is also now
included since the free-threaded GC must scan those too.
(cherry picked from commit e38967ed60778146050cc88dd16b70bfd867fde7)
[3.14] gh-142534: Avoid TSan warnings in dictobject.c (gh-142544) (gh-142603)
There are places we use "relaxed" loads where C11 requires "consume" or
stronger. Unfortunately, compilers don't really implement "consume" so
fake it for our use in a way that avoids upsetting TSan.
(cherry picked from commit 0a62f8277e9a0dd9f34b0b070adb83994e81b2a8)
PyUnstable_Object_IsUniqueReferencedTemporary wasn't handling tagged
ints on the evaluation stack properly.
(cherry picked from commit a26c831bc486b6e607cee6a5923bad52b97c2341)