Commit graph

8843 commits

Author SHA1 Message Date
Miss Islington (bot)
3944e9b3b2
[3.14] gh-140431: Fix GC crash due to partially initialized coroutines (gh-140470) (gh-140504)
Some checks are pending
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
The `make_gen()` function creates and tracks generator/coro objects, but
doesn't fully initialize all the fields. At a minimum, we need to
initialize all the fields that may be accessed by gen_traverse because
the call to `compute_cr_origin()` can trigger a GC.
(cherry picked from commit 574405c19e)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-10-23 14:44:21 +00:00
Mark Shannon
d1a434f7b2
[3.14] GH-139951: Fix major GC performance regression. Backport of GH-140262 (GH-140447)
* Count number of actually tracked objects, instead of trackable objects. This ensures that untracking tuples has the desired effect of reducing GC overhead
* Do not track most untrackable tuples during creation. This prevents large numbers of small tuples causing execessive GCs.
2025-10-23 15:26:58 +01:00
Miss Islington (bot)
9d547dab0b
[3.14] gh-132835: Add defensive NULL checks to MRO resolution (GH-134763) (GH-140436)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Currently, there are a few places where tp_mro could theoretically
become NULL, but do not in practice. This commit adds defensive checks for
NULL values to ensure that any changes do not introduce a crash and that
state invariants are upheld.

The assertions added in this commit are all instances where a NULL value would get passed to something not expecting a NULL, so it is better to catch an assertion failure than crash later on.

There are a few cases where it is OK for the return of lookup_tp_mro to be NULL, such as when passed to is_subtype_with_mro, which handles this explicitly.
(cherry picked from commit a8edca62fc)

Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-10-21 20:45:06 -07:00
Miss Islington (bot)
c0f0eca4da
[3.14] gh-140406: Fix memory leak upon __hash__ returning a non-integer (GH-140411) (GH-140417)
gh-140406: Fix memory leak upon `__hash__` returning a non-integer (GH-140411)
(cherry picked from commit 71db05a12d)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-10-21 12:35:31 +00:00
Miss Islington (bot)
045e34964a
[3.14] gh-140061: Use _PyObject_IsUniquelyReferenced() to check if objects are uniquely referenced (gh-140062) (gh-140157)
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>
2025-10-15 14:49:17 +00:00
Miss Islington (bot)
6b94c7ceeb
[3.14] gh-129559: Remove extra dot in bytearray.resize AC (GH-140134) (#140143)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
2025-10-15 14:06:18 +03:00
Miss Islington (bot)
2142f4efcf
[3.14] GH-140058: Clear key and value if PyTuple_New fails in dictiter_iternextitem (GH-140059) (#140107)
GH-140058: Clear key and value if `PyTuple_New` fails in `dictiter_iternextitem` (GH-140059)
(cherry picked from commit ded59f7e8e)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
2025-10-14 19:10:30 +05:30
Miss Islington (bot)
7a13953bc3
[3.14] gh-140000: Traverse name attribute for TypeVar, TypeVarTuple, TypeAliasType, ParamSpec (GH-140016) (#140063)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Docs (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
gh-140000: Traverse `name` attribute for `TypeVar`, `TypeVarTuple`, `TypeAliasType`, `ParamSpec` (GH-140016)
(cherry picked from commit be60e4b4f3)

Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
2025-10-13 20:36:24 +00:00
Kumar Aditya
511078099a
[3.14] gh-125996: fix thread safety of collections.OrderedDict (GH-133734) (#140053)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
(cherry picked from commit 6481539a6d)
2025-10-13 23:25:24 +05:30
Miss Islington (bot)
3b9694a8e6
[3.14] gh-139988: fix a leak when failing to create a Union type (GH-139990) (#139993)
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>
2025-10-12 11:16:43 +00:00
Miss Islington (bot)
09fdd219a5
[3.14] gh-105487: Fix __dir__ entries of GenericAlias (GH-138578) (GH-138629)
(cherry picked from commit b0420b505e)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-10-07 23:12:13 +02:00
Stan Ulbrych
a893270c6d
[3.14] gh-71648: Optimize PNG files (GH-138842) (GH-138851)
* Only keep > 1 kb savings
(cherry picked from commit 2e8f64c931)
2025-10-07 20:52:12 +02:00
Miss Islington (bot)
bf397e272c
[3.14] gh-133467: fix data race in type_set_name (GH-137302) (#137303)
gh-133467: fix data race in `type_set_name` (GH-137302)

Fix data race in `type_set_name` by assigning name under stop the world pause making it thread safe in free-threading.
(cherry picked from commit e99bc7fd44)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-07 18:18:23 +00:00
Miss Islington (bot)
bfcd5f25a5
[3.14] gh-138661: fix data race in PyCode_Addr2Line (GH-138664) (#138834)
gh-138661: fix data race in `PyCode_Addr2Line` (GH-138664)
(cherry picked from commit ea26f6da39)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-07 18:06:45 +00:00
Miss Islington (bot)
fad7bfc282
[3.14] gh-138902: Fix generator send arg name (GH-138905) (#138914)
gh-138902: Fix generator send arg name (GH-138905)
(cherry picked from commit cb07bd24ee)

Co-authored-by: Marat Khagazheev <marathagazeev@gmail.com>
Co-authored-by: marat <khagazheev@artlebedev.ru>
2025-10-07 23:27:05 +05:30
Miss Islington (bot)
57c8e3eb8e
[3.14] gh-58124: Avoid CP_UTF8 in UnicodeDecodeError (GH-137415) (#137460)
gh-58124: Avoid CP_UTF8 in UnicodeDecodeError (GH-137415)

Fix name of the Python encoding in Unicode errors of the code page
codec: use "cp65000" and "cp65001" instead of "CP_UTF7" and "CP_UTF8"
which are not valid Python code names.
(cherry picked from commit ce1b747ff6)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-07 19:39:31 +02:00
Miss Islington (bot)
b343009377
[3.14] gh-71810: Fix _PyLong_AsByteArray() undefined behavior (GH-138873) (#138883)
gh-71810: Fix _PyLong_AsByteArray() undefined behavior (GH-138873)

Don't read p[-1] when p is an empty string: when n==0.
(cherry picked from commit 8b5ce31c2b)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-07 19:38:40 +02:00
Sam Gross
85dabb9c15
[3.14] gh-137238: Fix data race in _Py_slot_tp_getattr_hook (gh-137240) (#137416)
Replacing the slot isn't thread-safe if the GIL is disabled. Don't
require that the slot has been replaced when specializing.
(cherry picked from commit 485b16b4f7)
2025-10-07 17:36:56 +00:00
Miss Islington (bot)
fbfbfdf33c
[3.14] gh-138479: Ensure that __typing_subst__ returns a tuple (GH-138482) (#138784)
Some checks are pending
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-12 16:23:03 +03:00
Miss Islington (bot)
440b83f838
[3.14] gh-71810: Fix corner case (length==0) for int.to_bytes() (GH-138739) (#138782)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-12 16:22:43 +03:00
Miss Islington (bot)
5086a1e8a0
[3.14] gh-138516: fix typo in OrderedDict exception msg (GH-138517) (#138523)
gh-138516: fix typo in OrderedDict exception msg (GH-138517)
(cherry picked from commit e9c2a357fb)

Co-authored-by: asas1asas200 <asas1asas200@gmail.com>
2025-09-05 11:02:21 +03:00
Miss Islington (bot)
019238ab18
[3.14] gh-137200: support frame lineno setter with BRANCH_LEFT and BRANCH_RIGHT events (GH-137229) (#137280)
Some checks are pending
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Co-authored-by: Xuanteng Huang <44627253+xuantengh@users.noreply.github.com>
2025-08-11 17:07:19 +03:00
Miss Islington (bot)
11f510167c
[3.14] gh-133296: Publicly expose critical section API that accepts PyMutex (gh-135899) (#136969)
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-07-22 12:44:59 +03:00
Lysandros Nikolaou
af8d1f56f5
[3.14] gh-132661: Disallow Template/str concatenation after PEP 750 spec update (#135996) (#136901)
Co-authored-by: Dave Peck <davepeck@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-07-21 17:34:54 +02:00
Miss Islington (bot)
9ae74e94a0
[3.14] gh-136396: Include instrumentation when creating new copies of the bytecode (GH-136525) (GH-136657)
Some checks are pending
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Previously, we assumed that instrumentation would happen for all copies of
the bytecode if the instrumentation version on the code object didn't match
the per-interpreter instrumentation version. That assumption was incorrect:
instrumentation will exit early if there are no new "events," even if there
is an instrumentation version mismatch.

To fix this, include the instrumented opcodes when creating new copies of
the bytecode, rather than replacing them with their uninstrumented variants.
I don't think we have to worry about races between instrumentation and creating
new copies of the bytecode: instrumentation and new bytecode creation cannot happen
concurrently. Instrumentation requires that either the world is stopped or the
code object's per-object lock is held and new bytecode creation requires holding
the code object's per-object lock.
(cherry picked from commit d995922198)

Co-authored-by: mpage <mpage@meta.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-07-15 11:10:37 -04:00
Miss Islington (bot)
348e22cf06
[3.14] gh-127971: fix off-by-one read beyond the end of a string during search (GH-132574) (#136628)
Some checks are pending
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
gh-127971: fix off-by-one read beyond the end of a string during search (GH-132574)
(cherry picked from commit 85ec3b3b50)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
2025-07-13 13:58:03 +00:00
Miss Islington (bot)
d5866a8e84
[3.14] gh-91153: prevent a crash in bytearray.__setitem__(ind, ...) when ind.__index__ has side-effects (GH-132379) (#136581)
gh-91153: prevent a crash in `bytearray.__setitem__(ind, ...)` when `ind.__index__` has side-effects (GH-132379)
(cherry picked from commit 5e1e21dee3)

Co-authored-by: Bast <52266665+bast0006@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-07-12 14:38:57 +00:00
Miss Islington (bot)
95baa28d9f
[3.14] gh-132661: Add default value (of "") for Interpolation.expression (GH-136441) (#136511)
Co-authored-by: Dave Peck <davepeck@gmail.com>
2025-07-10 14:52:18 +00:00
Miss Islington (bot)
6a2a2906f8
[3.14] GH-133136: Revise QSBR to reduce excess memory held (gh-135473) (#135912)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
The free threading build uses QSBR to delay the freeing of dictionary
keys and list arrays when the objects are accessed by multiple threads
in order to allow concurrent reads to proceed with holding the object
lock. The requests are processed in batches to reduce execution
overhead, but for large memory blocks this can lead to excess memory
usage.

Take into account the size of the memory block when deciding when to
process QSBR requests.

Also track the amount of memory being held by QSBR for mimalloc pages.  Advance the write sequence if this memory exceeds a limit.  Advancing the sequence will allow it to be freed more quickly.

Process the held QSBR items from the "eval breaker", rather than from `_PyMem_FreeDelayed()`.  This gives a higher chance that the global read sequence has advanced enough so that items can be freed.

(cherry picked from commit 113de8545f)

Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-07-08 10:58:01 -07:00
Miss Islington (bot)
46a7981f45
[3.14] GH-135106: Restrict trashcan to GC'ed objects (GH-135682) (#135876)
Co-authored-by: Mark Shannon <mark@hotpy.org>
2025-07-07 12:31:18 +03:00
Miss Islington (bot)
5b65df7925
[3.14] gh-109700: fix memory error handling in PyDict_SetDefault (GH-136338) (#136340)
gh-109700: fix memory error handling in `PyDict_SetDefault` (GH-136338)
(cherry picked from commit d22e073d2b)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-07-06 15:43:16 +00:00
Miss Islington (bot)
3ea7276a8e
[3.14] gh-129824: fix data races in subinterpreters under TSAN (GH-135794) (#136266)
gh-129824: fix data races in subinterpreters under TSAN (GH-135794)

This fixes the data races in typeobject.c in subinterpreters under free-threading. The type flags and slots are only modified in the main interpreter as all static types are first initialised in main interpreter.
(cherry picked from commit b582d751b4)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-07-06 18:53:55 +05:30
Victor Stinner
3267847759
[3.14] gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614) (#136119)
gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614)

(cherry picked from commit b1056c2a44)

Co-authored-by: Xuanteng Huang <44627253+xuantengh@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-06-30 15:59:22 +02:00
Miss Islington (bot)
1b218680b7
[3.14] gh-78465: Fix error message for cls.__new__(cls, ...) where cls is not instantiable (GH-135981) (GH-136030)
Previous error message suggested to use cls.__new__(), which
obviously does not work. Now the error message is the same as for
cls(...).
(cherry picked from commit c45f4f3ebe)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-27 12:01:48 +00:00
Miss Islington (bot)
a797fe180c
[3.14] gh-135755: Move PyFunction_GET_BUILTINS to the private API (GH-135938) (GH-135972)
(cherry picked from commit 10a3d43188)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-06-26 10:08:28 +00:00
Miss Islington (bot)
88c55528f5
[3.14] gh-135878: Fix crash in types.SimpleNamespace.__repr__ (GH-135889) (#135896)
gh-135878: Fix crash in `types.SimpleNamespace.__repr__` (GH-135889)
(cherry picked from commit b3ab94acd3)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-06-24 16:58:57 +00:00
Miss Islington (bot)
c03f94e7fe
[3.14] gh-135450: Remove assertion in _PyCode_CheckNoExternalState (gh-135694)
The assertion reflected a misunderstanding of situations where "hidden" variables might exist,
namely generator expressions and comprehensions.

(cherry picked from commit 15f2bac02c, AKA gh-135466)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-06-18 23:57:18 +00:00
Miss Islington (bot)
2b1c0a76dc
[3.14] gh-135443: Sometimes Fall Back to __main__.__dict__ For Globals (gh-135593)
Some checks failed
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Tail calling interpreter / aarch64-apple-darwin/clang (push) Has been cancelled
Tail calling interpreter / aarch64-unknown-linux-gnu/gcc (push) Has been cancelled
Tail calling interpreter / x86_64-pc-windows-msvc/msvc (push) Has been cancelled
Tail calling interpreter / x86_64-apple-darwin/clang (push) Has been cancelled
Tail calling interpreter / free-threading (push) Has been cancelled
Tail calling interpreter / x86_64-unknown-linux-gnu/gcc (push) Has been cancelled
For several builtin functions, we now fall back to __main__.__dict__ for the globals
when there is no current frame and _PyInterpreterState_IsRunningMain() returns
true.  This allows those functions to be run with Interpreter.call().

The affected builtins:

* exec()
* eval()
* globals()
* locals()
* vars()
* dir()

We take a similar approach with "stateless" functions, which don't use any
global variables.

(cherry picked from commit a450a0ddec, AKA gh-135491)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-06-16 23:59:30 +00:00
Miss Islington (bot)
15f7bd4295
[3.14] gh-132617: Fix dict.update() mutation check (gh-134815) (gh-135581)
Use `ma_used` instead of `ma_keys->dk_nentries` for modification check
so that we only check if the dictionary is modified, not if new keys are
added to a different dictionary that shared the same keys object.
(cherry picked from commit d8994b0a77)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-06-16 17:19:58 +00:00
Miss Islington (bot)
f77a911c52
[3.14] gh-135437: Account For Duplicate Names in _PyCode_SetUnboundVarCounts() (gh-135493)
Some checks are pending
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
(cherry picked from commit 56eabea, AKA gh-135438)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-06-13 23:14:00 +00:00
Victor Stinner
3d69d18322
[3.14] gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973) (#134974)
gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)

Replace most PyUnicodeWriter_WriteUTF8() calls with
PyUnicodeWriter_WriteASCII().

(cherry picked from commit f49a07b531)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-09 14:37:26 +02:00
Miss Islington (bot)
7c1dfd9c98
[3.14] gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658) (#134964)
gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658)

random.getrandbits() can now generate more that 2**31 bits.
random.randbytes() can now generate more that 256 MiB.
(cherry picked from commit 68784fed78)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-31 20:02:38 -07:00
Miss Islington (bot)
9c2e0febb4
[3.14] gh-132775: Fix _PyFunctIon_VerifyStateless() (gh-134901)
gh-132775: Fix _PyFunctIon_VerifyStateless() ()

The problem we're fixing here is that we were using PyDict_Size() on "defaults",
which it is actually a tuple.  We're also adding some explicit type checks.

This is a follow-up to gh-133221/gh-133528.

(cherry picked from commit dafd14146f, AKA gh-134900)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-05-29 20:55:42 +00:00
Miss Islington (bot)
4670dddbf6
[3.14] GH-133912: Fix PyObject_GenericSetDict to handle inline values (GH-134725) (#134859) 2025-05-29 11:19:58 -07:00
Miss Islington (bot)
3681e3a831
[3.14] gh-134679: Fix assertion failure in QSBR (gh-134811) (gh-134814)
This is the same underlying bug as gh-130519. The destructor may call
arbitrary code, changing the `tstate->qsbr pointer` and invalidating the
old `struct _qsbr_thread_state`.
(cherry picked from commit a4d37f88b6)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-05-27 20:46:02 +00:00
Pablo Galindo Salgado
1822f33b1a
[3.14] gh-91048: Refactor and optimize remote debugging module (#134652) (#134673)
gh-91048: Refactor and optimize remote debugging module (#134652)

Completely refactor Modules/_remote_debugging_module.c with improved
code organization, replacing scattered reference counting and error
handling with centralized goto error paths. This cleanup improves
maintainability and reduces code duplication throughout the module while
preserving the same external API.

Implement memory page caching optimization in Python/remote_debug.h to
avoid repeated reads of the same memory regions during debugging
operations. The cache stores previously read memory pages and reuses
them for subsequent reads, significantly reducing system calls and
improving performance.

Add code object caching mechanism with a new code_object_generation
field in the interpreter state that tracks when code object caches need
invalidation. This allows efficient reuse of parsed code object metadata
and eliminates redundant processing of the same code objects across
debugging sessions.

Optimize memory operations by replacing multiple individual structure
copies with single bulk reads for the same data structures. This reduces
the number of memory operations and system calls required to gather
debugging information from the target process.

Update Makefile.pre.in to include Python/remote_debug.h in the headers
list, ensuring that changes to the remote debugging header force proper
recompilation of dependent modules and maintain build consistency across
the codebase.

Also, make the module compatible with the free threading build as an extra :)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>

(cherry picked from commit 42b25ad4d3)
2025-05-25 22:10:20 +00:00
Miss Islington (bot)
d82d445b18
[3.14] gh-133778: Fix setting __annotations__ under PEP 563 (GH-133794) (#134655)
gh-133778: Fix setting `__annotations__` under PEP 563 (GH-133794)
(cherry picked from commit 4443110c34)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-05-25 16:04:22 +00:00
Miss Islington (bot)
87d7a19ef0
[3.14] gh-133980: use atomic store in PyObject_GenericSetDict (GH-133988) (#134354)
gh-133980: use atomic store in `PyObject_GenericSetDict` (GH-133988)
(cherry picked from commit ec39fd2c20)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-05-21 15:06:39 +05:30
Miss Islington (bot)
1ba5e65b76
[3.14] gh-134119: Fix crash from calling next() on exhausted template iterator (GH-134120) (#134153)
gh-134119: Fix crash from calling next() on exhausted template iterator (GH-134120)
(cherry picked from commit fc7f4c3666)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-05-17 19:48:54 +00:00
Miss Islington (bot)
f2a4b1066b
[3.14] gh-133970: Make PEP750 types generic (GH-133976) (#134029)
gh-133970: Make PEP750 types generic (GH-133976)
(cherry picked from commit c3a1da5b93)

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-05-15 06:39:39 +00:00