Commit graph

15869 commits

Author SHA1 Message Date
Miss Islington (bot)
54ee910bcd
[3.15] gh-151126: Fix missing memory errors in _interpchannelsmodule.c (GH-151239) (#151265)
gh-151126: Fix missing memory errors in `_interpchannelsmodule.c` (GH-151239)
(cherry picked from commit 9fd1a125bc)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-10 16:26:38 +00:00
Miss Islington (bot)
9261f8b588
[3.15] gh-143988: Fix re-entrant mutation crashes in socket sendmsg/recvmsg_into (GH-143987) (#151246)
gh-143988: Fix re-entrant mutation crashes in socket sendmsg/recvmsg_into (GH-143987)

Fix crashes in socket.sendmsg() and socket.recvmsg_into() that could
occur if buffer sequences are mutated re-entrantly during argument
parsing via __buffer__ protocol callbacks.

The bug occurs because:

1. PySequence_Fast() returns the original list object when the input
   is already a list (not a copy).
2. During iteration, PyObject_GetBuffer() triggers __buffer__
   callbacks which may clear the list.
3. Subsequent iterations access invalid memory (heap OOB read).

The fix replaces PySequence_Fast() with PySequence_Tuple() which
always creates a new tuple, ensuring the sequence cannot be mutated
during iteration.
(cherry picked from commit 896f7fdc7d)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: tonghuaroot <23011166+tonghuaroot@users.noreply.github.com>
2026-06-10 14:25:33 +00:00
Cody Maloney
0318867acf
[3.15] gh-143008: Fix race re-initializing TextIOWrapper (#151203)
__init__() changes multiple variables and may be called more than once
from multiple threads.
2026-06-10 11:13:46 +02:00
Miss Islington (bot)
489d6af9af
[3.15] gh-151126: Add missing PyErr_NoMemory in _winapi module (GH-151154) (#151180)
gh-151126: Add missing `PyErr_NoMemory` in `_winapi` module (GH-151154)
(cherry picked from commit 8d94fa7b86)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-09 17:10:18 +00:00
Miss Islington (bot)
3199f3ba29
[3.15] gh-151039: Fix a crash when _datetime types outlive _datetime module (GH-151044) (#151143)
gh-151039: Fix a crash when `_datetime` types outlive `_datetime` module (GH-151044)
(cherry picked from commit 9fdbade99e)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-09 12:14:47 +00:00
Miss Islington (bot)
2d432f21db
[3.15] gh-151130: Add more tests for PyWeakref_* C API (GH-151131) (GH-151140)
(cherry picked from commit c3cd75afdf)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-06-09 11:37:56 +00:00
Pablo Galindo Salgado
83e26a43a7
[3.15] gh-149321: Remove lazy_imports=none startup mode (GH-149389) (#150129) 2026-06-08 22:55:57 +00:00
Miss Islington (bot)
99979753b3
[3.15] gh-149816: Fix SNI callback callable race (GH-150018) (GH-150099)
(cherry picked from commit 8b31d08e62)

Co-authored-by: Kirill Ignatev <kiri11@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-06-08 21:01:31 +03:00
Miss Islington (bot)
d3ca26983d
[3.15] gh-150599: Prevent bz2 decompressor reuse after errors (GH-150600)
(cherry picked from commit 5755d0f083)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-07 17:48:30 +01:00
Miss Islington (bot)
a642d1ab38
[3.15] gh-151021: Fix mmap empty searches past the end (GH-151023) (GH-151041)
(cherry picked from commit f2cab7b0cf)

Co-authored-by: esadomer <54475303+esadomer@users.noreply.github.com>
2026-06-07 13:27:26 +00:00
Miss Islington (bot)
c6d64cc60d
[3.15] gh-150913: Fix sqlite3.Blob validation for empty slice assignment (GH-150915) (GH-150923)
ass_subscript_slice() returned early when the computed slice length
was zero, bypassing validation performed for non-empty slices.
(cherry picked from commit fc9c4db130)

Co-authored-by: Jiseok CHOI <jiseok.dev@gmail.com>
2026-06-04 14:10:30 +00:00
Miss Islington (bot)
42a41cc69f
[3.15] gh-150750: Fix a race condition in deque.index with free-threading (GH-150779) (#150920)
gh-150750: Fix a race condition in `deque.index` with free-threading (GH-150779)
(cherry picked from commit d83d50b5b7)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-04 13:58:59 +00:00
Miss Islington (bot)
0ad93968fe
[3.15] gh-149473: Emit audit event on calling os.environ.clear() (GH-149768) (#150094)
gh-149473: Emit audit event on calling os.environ.clear() (GH-149768)
(cherry picked from commit 29415c071f)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-04 08:47:38 +00:00
Miss Islington (bot)
624384d974
[3.15] gh-149521: Do not update last_profiled_frame if it's not changed (GH-149522) (#149542)
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-06-04 11:31:47 +03:00
Miss Islington (bot)
d7505294df
[3.15] gh-148613: Fix race in gc_set_threshold and gc_get_threshold (GH-150356) (#150841)
gh-148613: Fix race in `gc_set_threshold` and `gc_get_threshold` (GH-150356)
(cherry picked from commit 41eb8ee2bb)

Co-authored-by: Edward Xu <xuxiangad@gmail.com>
2026-06-04 12:43:46 +05:30
Miss Islington (bot)
1c2daa08fb
[3.15] gh-150319: Replace all documentation which says "See PEP 585" (GH-150325) (#150808)
gh-150319: Replace all documentation which says "See PEP 585" (GH-150325)

* Replace all documentation which says "See PEP 585"

The following classes in the stdlib get simple updates:

- array.array
- asyncio.Future
- asyncio.Task
- collections.defaultdict
- collections.deque
- contextvars.ContextVar
- contextvars.Token
- ctypes.Array
- os.DirEntry
- re.Match
- re.Pattern
- string.templatelib.Interpolation
- string.templatelib.Template
- types.MappingProxyType
- queue.SimpleQueue
- weakref.ref

The following classes are documented publicly as functions, and are
therefore updated internally (`__class_getitem__.__doc__`) but not in the
public docs:

- functools.partial
- itertools.chain

The following builtin types have updates to `__class_getitem__.__doc__`
but not to any documentation pages:

- BaseExceptionGroup
- coroutines (from generators)
- dict
- enumerate
- frozendict
- frozenset
- generators (and async generators)
- list
- memoryview
- set
- slice
- tuple

Special cases:

- union objects are now documented as "supporting class-level []",
  rather than anything to do with generics.

- Templates might be generic over a single type (union, in theory) or
  over a TypeVarTuple. As this is not currently fully settled, it is
  marked with a comment and a mild hint that it is a single type is used
  (namely, "type" is singular rather than "types", plural)

* Apply suggestions from code review



* Correct several class getitem docs

And expand the text for tuples.



* Add notes on generic typing of builtins

* Fix typo in tuple.__class_getitem__ docstring

* Typo fix: malformed refs

Fix `generic` links which weren't marked as `:ref:`.

* Strike unnecessary docs on generic-ness



* Apply suggestions from code review

These are applied at both the originally indicated locations and in the
corresponding docstring definitions.



* Update Doc/library/re.rst



* Update Objects/enumobject.c



* Remove tuple generic doc in 'stdtypes' page

This is covered in more detail in the cross-linked typing documentation.
The other copy of this documentation -- in the docstring for
`tuple.__class_getitem__` -- is left in place.

* Fix whitespace around new doc of generics

Per review, do not introduce or remove whitespace such that section
breaks are altered by the introduction of doc on various generic types.

In most cases, this is a removal of an extra line.

In one case (Arrays), it is the reintroduction of a line.

Additionally, two other minor fixes are included:
- incorrect indent on 'defaultdicts'
- make `mappingproxy.__class_getitem__.__doc__` consistent with other
  mapping type generic docs



* Move placement of memoryview generic note

Previous placement was at the end of the main docstring, which is
consistent with other types but places it after a section on various
methods (which makes it read somewhat inconsistently). Moving it up
helps resolve.



* Ensure sphinxdoc does not start sentences lowercase

Lowercase class names at the start of sentences are marked out with the
`class` role. In the case of `deque`, documentation already refers to
these as `Deques`, so this form is preferred.

* Apply suggestions from code review



* Fix line endings and wrap more tightly

Line endings fixed by pre-commit ; also re-wrapped the MappingProxyType
text which was too long.

* Use 'ContextVars' style in sphinx doc

---------
(cherry picked from commit 50fe49c879)

Co-authored-by: Stephen Rosen <sirosen@globus.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <906600+JelleZijlstra@users.noreply.github.com>
Co-authored-by: Alex Waygood <66076021+AlexWaygood@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-02 20:40:52 +00:00
Miss Islington (bot)
c5512bd7c1
[3.15] gh-149079: Fix O(n^2) canonical ordering in unicodedata.normalize() (GH-149080) (#150776)
Replace the insertion sort used for canonical ordering of combining
characters with a hybrid approach: insertion sort for short runs (< 20)
and counting sort for longer runs, reducing worst-case complexity from
O(n^2) to O(n). This prevents denial of service via crafted Unicode
strings with many combining characters in alternating CCC order.
(cherry picked from commit 991224b1e8)

Co-authored-by: Seth Larson <seth@python.org>
Co-authored-by: ch4n3-yoon <ch4n3.yoon@gmail.com>
Co-authored-by: Seokchan Yoon <13852925+ch4n3-yoon@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-06-02 10:10:04 +00:00
Miss Islington (bot)
1835400ff5
[3.15] gh-149738: Fix segmentation fault bug in sqllite3 (GH-149754) (#150768)
gh-149738: Fix segmentation fault bug in sqllite3 (GH-149754)

Deleting the `row_factory` or `text_factory` attribute is no longer allowed.
(cherry picked from commit 60fdb3192b)

Co-authored-by: Sepehr Rasouli <sepehrrasouli06@gmail.com>
2026-06-02 09:36:03 +00:00
Miss Islington (bot)
3a12e9f524
[3.15] gh-149534: Fix unification of defaultdict and frozendict with | (GH-149539) (#150709)
gh-149534: Fix unification of `defaultdict` and `frozendict` with `|` (GH-149539)
(cherry picked from commit cc0269334f)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-01 16:07:33 +00:00
Miss Islington (bot)
b65c28206f
[3.15] gh-150157: Fix critical section for PyDict_Next() in _pickle.c (GH-150158) (#150711)
(cherry picked from commit c5516e7e37)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
2026-06-01 14:59:09 +00:00
Miss Islington (bot)
e60e8cfe8b
[3.15] gh-149046: fix: correctly handle str subclasses in io.StringIO (GH-149047) (#150706)
gh-149046: fix: correctly handle `str` subclasses in `io.StringIO` (GH-149047)
(cherry picked from commit c98773633c)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
2026-06-01 13:33:02 +00:00
Miss Islington (bot)
4ce8de3550
[3.15] gh-150372: Add missing null check on completer_word_break_characters in readline.c (GH-150251) (GH-150628)
(cherry picked from commit 56bd9ea676)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
2026-06-01 10:00:55 +00:00
Miss Islington (bot)
c5655dfe51
[3.15] Correct frexp() docs for zero and non-finite numbers (GH-149753) (GH-150652)
0.5 <= abs(m) < 1 is only true for finite nonzero numbers
(cherry picked from commit 5b5ffce05c)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-05-31 10:04:18 +00:00
Miss Islington (bot)
7cf2b37b66
[3.15] gh-150406: Check result of PyThread_allocate_lock() for netdb_lock (GH-150407) (GH-150616)
(cherry picked from commit 1e18c45495)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
2026-05-30 17:15:02 +00:00
Miss Islington (bot)
d2b10e75c7
[3.15] gh-149571: Fix the C implementation of Element.itertext() (GH-149929) (GH-150509)
It no longer emits text for comments and processing instructions.
(cherry picked from commit 7de4fcd445)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-27 10:52:02 +00:00
Miss Islington (bot)
d73e43317e
[3.15] gh-149931: Fix memory leaks on failed realloc (GH-149932) (#150439) 2026-05-26 01:04:49 +00:00
Pablo Galindo Salgado
d5381e18b8
[3.15] gh-149619: Harden _remote_debugging error paths (GH-150349) (#150435)
(cherry picked from commit a5be25d3bd)
2026-05-25 23:02:37 +00:00
Miss Islington (bot)
c95aa3aeb1
[3.15] gh-149449: Fix use-after-free in _PyUnicode_GetNameCAPI (GH-150323) (#150352)
gh-149449: Fix use-after-free in `_PyUnicode_GetNameCAPI` (GH-150323)
(cherry picked from commit 43c60ec2fd)

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-05-25 07:05:24 +00:00
Serhiy Storchaka
cf73b17adf
[3.15] gh-150285: Fix too long docstrings in Argument Clinic code (GH-150338) (GH-150350)
(cherry picked from commit 287c98f4cb)
2026-05-24 22:31:19 +03:00
Serhiy Storchaka
739552caae
[3.15] gh-150285: Fix too long docstrings in the os module (GH-150296) (GH-150341)
(cherry picked from commit a5cb7c34dd)
2026-05-24 13:53:29 +00:00
Miss Islington (bot)
79937e3cf1
[3.15] gh-150285: Fix too long docstrings in the sqlite3 module (GH-150290) (GH-150340)
(cherry picked from commit 0466560b31)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-24 13:43:38 +00:00
Miss Islington (bot)
baf22f34ca
[3.15] gh-150285: Fix too long docstrings in the pyexpat module (GH-150294) (GH-150337)
(cherry picked from commit 9da7923835)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-24 13:41:40 +00:00
Miss Islington (bot)
3573b3b1ec
[3.15] gh-149018: Use XML_SetHashSalt16Bytes in pyexpat/_elementtree when possible (#149645)
(cherry picked from commit 24b8f12544)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-24 14:36:30 +01:00
Miss Islington (bot)
d3e2a133d2
[3.15] gh-150285: Fix too long docstrings in the zstd module (GH-150291) (GH-150335)
(cherry picked from commit 9fceb1c0c5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-24 16:24:34 +03:00
Miss Islington (bot)
e8f534d1af
[3.15] gh-150285: Fix too long docstrings in the decimal module (GH-150288) (GH-150333)
(cherry picked from commit 6bed57a3b6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-24 16:24:08 +03:00
Miss Islington (bot)
cfb2e431cd
[3.15] gh-150285: Fix too long docstrings in the io module (GH-150287) (GH-150332)
(cherry picked from commit 160dc74122)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-24 16:23:45 +03:00
Miss Islington (bot)
29cbb44200
[3.15] gh-150285: Fix too long docstrings in the curses module (GH-150286) (GH-150331)
(cherry picked from commit 4c0fe2d134)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-24 16:23:25 +03:00
Miss Islington (bot)
1b7ab11cd6
[3.15] gh-150285: Fix too long docstrings in the _remote_debugging module (GH-150289) (#150334)
gh-150285: Fix too long docstrings in the _remote_debugging module (GH-150289)
(cherry picked from commit cdc499ae77)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-24 14:09:13 +01:00
Miss Islington (bot)
ca59d7511e
[3.15] gh-149816: add missing critical section on self in buffered_iternext (GH-150295) (#150305)
gh-149816: add missing critical section on self in buffered_iternext (GH-150295)
(cherry picked from commit e8545ed3ea)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-05-23 09:25:56 +00:00
Miss Islington (bot)
77cc4428a7
[3.15] gh-146452: Fix pickle segfault on concurrent mutation of dict in pickle (GH-146470) (#150292)
gh-146452: Fix pickle segfault on concurrent mutation of dict in pickle (GH-146470)
(cherry picked from commit e62a61177f)

Co-authored-by: Farhan Saif <fsaif@uic.edu>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-05-23 07:33:21 +00:00
Victor Stinner
795dd3bd35
[3.15] Revert "[3.15] gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (GH-150025) (#150039)" (#150262)
Revert "[3.15] gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (GH-150025) (#150039)"

This reverts commit 66ade2861f.
2026-05-23 12:27:27 +05:30
Miss Islington (bot)
f5231469b5
[3.15] gh-148829: Make sentinels' repr and module customizable (GH-149654) (#150092)
Implementation of python/peps#4968.
(cherry picked from commit 08218030a5)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-22 07:44:34 -07:00
Miss Islington (bot)
034c536d56
[3.15] gh-149584: Fix excessive overhead in the Tachyon profiler regarding the cache behavior (GH-149649) (#150152) 2026-05-20 11:59:10 +00:00
Miss Islington (bot)
d6dda0d23c
[3.15] gh-150042: queue.SimpleQueue.put: fix minor refleak. (GH-150043) (GH-150127)
If queue.SimpleQueue.put can't handoff the item to a
waiting thread, and fails to allocate memory when adding
the item to a ringbuf, it would leak a reference.  Fixed.
(cherry picked from commit 79088e0d82)

Co-authored-by: larryhastings <larry@hastings.org>
2026-05-20 02:46:42 +02:00
Miss Islington (bot)
f46b397975
[3.15] gh-149983: Fix PyErr_NoMemory call without GIL in winconsoleio.c (GH-149984) (GH-150113)
(cherry picked from commit 3d2aa899ba)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-05-19 23:11:13 +02:00
Miss Islington (bot)
66ade2861f
[3.15] gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (GH-150025) (#150039)
gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (GH-150025)

Remove assertion that could fail in rare race condition.

Replace the coarse critical section wrapping the entire function with
fine-grained sections covering only PyDict_Next + Py_INCREF.
Also handle PyDict_Next returning 0 in the single-item fast path.
(cherry picked from commit 57a0e570d3)

Co-authored-by: Saul Cooperman <58375603+scopreon@users.noreply.github.com>
2026-05-18 23:53:57 +00:00
Miss Islington (bot)
c417fcabfd
[3.15] gh-149590: Remove faulthandler_traverse (GH-150023) (#150037)
gh-149590: Remove faulthandler_traverse (GH-150023)

`faulthandler_traverse` visits Python objects owned by `_PyRuntime`, not
by the module instance. With multi-phase init allowing multiple module
instances, each instance's GC traversal decrements `gc_refs` on the same
runtime-owned objects, driving it negative when two instances are
collected simultaneously.
(cherry picked from commit 56737483c2)

Co-authored-by: Armaan Vakharia <43391096+armaan-v924@users.noreply.github.com>
2026-05-18 23:28:04 +00:00
Miss Islington (bot)
01b07df858
[3.15] gh-149816: Fix a RC in _random.Random.__init__ method (GH-149824) (#149997)
gh-149816: Fix a RC in `_random.Random.__init__` method (GH-149824)
(cherry picked from commit 14af19e6c0)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-18 16:16:55 +00:00
Miss Islington (bot)
6e83c55e64
[3.15] gh-149953: Fix null pointer dereference order in code_objects.c (GH-149956) (#149976)
gh-149953: Fix null pointer dereference order in `code_objects.c` (GH-149956)

Move  check before
(cherry picked from commit 0ed497a350)

Co-authored-by: Nezuko Agent <nezukoagent@gmail.com>
2026-05-18 09:00:19 +00:00
Miss Islington (bot)
42ff9b4959
[3.15] gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922) (#149943)
gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922)
(cherry picked from commit acefff95ea)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-05-17 11:01:15 +00:00