Commit graph

15312 commits

Author SHA1 Message Date
Serhiy Storchaka
1e72dfadf6
[3.14] gh-150285: Fix too long docstrings in the os module (GH-150296) (GH-150341) (GH-150464)
(cherry picked from commit 739552caae)
(cherry picked from commit a5cb7c34dd)
2026-05-26 09:39:54 +00:00
Serhiy Storchaka
ad1bb6c14c
[3.14] gh-150285: Fix too long docstrings in the pyexpat module (GH-150294) (GH-150463)
(cherry picked from commit 9da7923835)
2026-05-26 09:34:51 +00:00
Serhiy Storchaka
7168b02795
[3.14] gh-150285: Fix too long docstrings in the sqlite3 module (GH-150290) (GH-150461)
(cherry picked from commit 0466560b31)
2026-05-26 09:27:04 +00:00
Serhiy Storchaka
36137e46a8
[3.14] gh-150285: Fix too long docstrings in the io module (GH-150287) (GH-150458)
(cherry picked from commit 160dc74122)
2026-05-26 09:10:39 +00:00
Serhiy Storchaka
e7f1216204
[3.14] gh-150285: Fix too long docstrings in the curses module (GH-150286) (GH-150457)
(cherry picked from commit 4c0fe2d134)
2026-05-26 09:06:00 +00:00
Serhiy Storchaka
09ff114e8c
[3.14] gh-150285: Fix too long docstrings in the zstd module (GH-150291) (GH-150335) (#150421)
(cherry picked from commit 9fceb1c0c5)
(cherry picked from commit d3e2a133d2)

Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
2026-05-25 16:05:41 -07:00
Miss Islington (bot)
ec4df59134
[3.14] gh-149449: Fix use-after-free in _PyUnicode_GetNameCAPI (GH-150323) (#150353)
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 12:16:08 +05:30
Miss Islington (bot)
2d94a6e85e
[3.14] gh-149816: add missing critical section on self in buffered_iternext (GH-150295) (#150306)
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 14:56:44 +05:30
Victor Stinner
0bd80a1d48
[3.14] Revert "[3.14] gh-146452: Improve locking granularity in pickle's batch_dict_… (#150062)" (#150263)
Revert "[3.14] gh-146452: Improve locking granularity in pickle's batch_dict_… (#150062)"

This reverts commit 1243cd677d.
2026-05-23 12:28:19 +05:30
Shamil
bba6c1d9d5
[3.14] gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851) (#150078)
gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851)

User callbacks invoked during JSON encoding (e.g. the `default` callback or
a custom string encoder) can mutate or clear the dict or sequence being
encoded, invalidating borrowed references to items, keys, and values. Hold
strong references unconditionally while iterating.



(cherry picked from commit 235fa7244a)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-19 20:31:43 -07:00
Miss Islington (bot)
2744371e4f
[3.14] gh-149816: Fix SNI callback callable race (GH-150018) (GH-150100)
(cherry picked from commit 8b31d08e62)

Co-authored-by: Kirill Ignatev <kiri11@users.noreply.github.com>
2026-05-20 00:05:42 +02:00
Miss Islington (bot)
07e368879d
[3.14] gh-149983: Fix PyErr_NoMemory call without GIL in winconsoleio.c (GH-149984) (GH-150111)
(cherry picked from commit 3d2aa899ba)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-05-19 23:11:43 +02:00
Armaan Vakharia
fa9773ed9d
[3.14] gh-149590: Remove faulthandler_traverse (GH-150023) (#150088)
`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)
2026-05-19 15:08:58 +00:00
Saul Cooperman
1243cd677d
[3.14] gh-146452: Improve locking granularity in pickle's batch_dict_… (#150062)
[3.14] 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)
2026-05-19 05:34:06 -07:00
Miss Islington (bot)
21a72363f9
[3.14] gh-149816: Fix a RC in _random.Random.__init__ method (GH-149824) (#149998)
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:19:23 +00:00
Miss Islington (bot)
dc86a1bdf3
[3.14] gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922) (#149944)
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 10:35:27 +00:00
Miss Islington (bot)
f380f85e61
[3.14] gh-146452: Fix pickle segfault on concurrent mutation of dict in pickle (GH-146470) (#149940)
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-17 09:30:00 +00:00
Victor Stinner
98c036b084
[3.14] gh-149707: Fix compiler warning in _ctypes_test on strchr() (#149791) (#149866)
gh-149707: Fix compiler warning in _ctypes_test on strchr() (#149791)

Change my_strchr() return type to "const char*" (add "const").

Fix the compiler warning:

Modules/_ctypes/_ctypes_test.c: In function 'my_strchr':
Modules/_ctypes/_ctypes_test.c:451:12: warning: return discards
'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  451 |     return strchr(s, c);
      |            ^~~~~~

When using C23, strchr(text, ch) return type is "const char*" if text
type is "const char*".

(cherry picked from commit 5465b69255)
2026-05-15 11:36:01 +00:00
Miss Islington (bot)
5f8fdda960
[3.14] gh-149698: Update bundled expat to 2.8.1 (GH-149699) (#149813)
(cherry picked from commit f1a47e79fb)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-14 09:53:10 +01:00
Sam Gross
d6b6fd70c4
[3.14] gh-145235: Make dict watcher API thread-safe for free-threaded builds (gh-145233) (#149691)
In free-threaded builds, concurrent calls to PyDict_AddWatcher, PyDict_ClearWatcher, PyDict_Watch, and PyDict_Unwatch can race on the shared callback array and the per-dict watcher tags. This change adds a mutex to serialize watcher registration and removal, atomic operations for tag updates, and atomic acquire/release synchronization for callback dispatch in _PyDict_SendEvent.

(cherry picked from commit 8a4895985f)

Co-authored-by: Alper <alperyoney@fb.com>
2026-05-12 13:21:31 -04:00
Miss Islington (bot)
6588ca5b64
[3.14] gh-148441: Avoid integer overflow in Expat's CharacterDataHandler (GH-148904) (#149638)
gh-148441: Avoid integer overflow in Expat's CharacterDataHandler (GH-148904)
(cherry picked from commit bc1be4f617)

Co-authored-by: ByteFlow <fakeshadow1337@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-05-10 14:08:59 +00:00
Pablo Galindo Salgado
316f6265b7
[3.14] gh-148178: Validate remote debug offset tables on load (GH-148187) (#148577)
Treat the debug offset tables read from a target process as untrusted input
and validate them before the unwinder uses any reported sizes or offsets.

Add a shared validator in debug_offsets_validation.h and run it once when
_Py_DebugOffsets is loaded and once when AsyncioDebug is loaded. The checks
cover section sizes used for fixed local buffers and every offset that is
later dereferenced against a local buffer or local object view. This keeps
the bounds checks out of the sampling hot path while rejecting malformed
tables up front.
(cherry picked from commit 289fd2c97a)
2026-05-04 22:43:43 +01:00
Miss Islington (bot)
3e25cd9619
[3.14] gh-148093: Raise binascii.Error from binascii.a2b_uu() on empty input (GH-149077) (GH-149350)
Instead of reading past the end of the empty buffer.
(cherry picked from commit 0c6d2f64c0)

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-05-04 10:10:47 +00:00
Zachary Ware
6297185237
[3.14] gh-149254: Update CI to use latest OpenSSL versions (GH-149333)
Also update Modules/_ssl_data_35.h to include an added symbol from 3.5.6.

(adapted from commit 68fe899feb)
2026-05-03 21:11:42 +00:00
Miss Islington (bot)
5ec845a044
[3.14] gh-148967: Fix FFI type pointer handling for C complex support in set_stginfo_ffi_type_pointer (GH-148969) (GH-149224)
(cherry picked from commit f2c7c0d2b7)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-05-01 15:43:38 +02:00
Sergey Miryanov
4d0ae4cba9
[3.14] GH-148726: Add heap_size to _gc_runtime_state (#149025) 2026-04-29 13:04:11 +03:00
Stan Ulbrych
c181c5fa16
[3.14] gh-149017: Upgrade bundled Expat to 2.8.0 (GH-149020) (#149073)
(cherry picked from commit 005555a3f0)
2026-04-28 16:30:12 +03:00
Miss Islington (bot)
22d53a9141
[3.14] gh-148529: Minor improvements of the struct module documentation (GH-148565) (GH-149063)
* Document that 's' and 'p' accept bytes and bytearray.
* Fix some footnotes.
* Clarify that "string" is a byte string.
* Fix the module docstring.
(cherry picked from commit 3e5a3cb2bd)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-04-27 23:07:00 +03:00
Sergey Miryanov
9a7e205e46
[3.14] GH-148726: Forward-port generational GC (#148720)
Co-authored-by: Neil Schemenauer <nas@arctrix.com>
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
2026-04-26 21:12:52 +03:00
Miss Islington (bot)
8acb98a1c2
[3.14] gh-148973: fix segfault on mismatch between consts size and oparg in compiler (GH-148974) (#148980)
gh-148973: fix segfault on mismatch between consts size and oparg in compiler (GH-148974)
(cherry picked from commit c650b51c32)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-04-25 13:53:42 +01:00
Miss Islington (bot)
89f44ac422
[3.14] gh-148735: Fix a UAF in Element.findtext() (GH-148738) (#148916)
(cherry picked from commit 0469e6d38d)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-24 21:38:15 +01:00
Miss Islington (bot)
0f656e2641
[3.14] gh-148484: Fix memory leak of iterator in array.array constructor (GH-148523) (GH-148678)
(cherry picked from commit afde75664e)

Co-authored-by: Gleb Popov <gvpopov.dev@gmail.com>
2026-04-23 16:00:37 +02:00
Miss Islington (bot)
5e758ff525
[3.14] gh-148464: Add missing `__ctype_le/be__` attributes for complex types in the ctype module (GH-148485) (GH-148677)
(cherry picked from commit 769cc8338f)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-04-23 15:57:55 +02:00
Stan Ulbrych
5f1b710a28
[3.14] gh-148801: Fix unbound C recursion in Element.__deepcopy__() (GH-148802) (#148842)
(cherry picked from commit 33e82be174)
2026-04-22 22:19:25 +01:00
Miss Islington (bot)
5aa8234cce
[3.14] gh-146578: _zstd: Fix printf format for pledged size errors (GH-146576) (#148855)
gh-146578: _zstd: Fix printf format for pledged size errors (GH-146576)

Use %llu instead of %ull for unsigned long long in zstd_contentsize_converter ValueError messages.
(cherry picked from commit 09233bd198)

Co-authored-by: cui <cuiweixie@gmail.com>
2026-04-21 13:31:46 -07:00
Miss Islington (bot)
27522b7d6e
[3.14] gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809) (#148837)
gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809)
(cherry picked from commit 1274766d3c)

Co-authored-by: Seth Larson <seth@python.org>
2026-04-21 21:56:19 +05:30
Miss Islington (bot)
7f6a0c377b
[3.14] gh-148651: Fix refcount leak in _zstd decompressor options (GH-148657) (#148691)
gh-148651: Fix refcount leak in _zstd decompressor options (GH-148657)

The option parsing in Modules/_zstd/decompressor.c had a missing Py_DECREF(value) before the early return -1 when PyLong_AsInt(key) fails. The identical code in Modules/_zstd/compressor.c line 158 has the fix.
(cherry picked from commit 446edda209)

Co-authored-by: Michael Bommarito <michael.bommarito@gmail.com>
2026-04-17 16:07:54 +00:00
Miss Islington (bot)
6a5f79c8d7
[3.14] gh-148395: Fix a possible UAF in {LZMA,BZ2,_Zlib}Decompressor (GH-148396) (#148480)
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>
2026-04-13 01:40:54 +00:00
Miss Islington (bot)
4f8a77bf3f
[3.14] gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106) (#148404)
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>
2026-04-11 22:46:26 +00:00
Miss Islington (bot)
bb78ec8fa8
[3.14] gh-148274: properly handle result from PyObject_VisitManagedDict (GH-148275) (#148295)
gh-148274: properly handle result from `PyObject_VisitManagedDict` (GH-148275)
(cherry picked from commit ee2775cfae)

Co-authored-by: Max Bachmann <kontakt@maxbachmann.de>
2026-04-09 13:49:09 +00:00
Miss Islington (bot)
07158b605d
[3.14] gh-146613: Fix re-entrant use-after-free in itertools._grouper (GH-147962) (#148010)
gh-146613: Fix re-entrant use-after-free in `itertools._grouper` (GH-147962)
(cherry picked from commit fc7a188fe7)

Co-authored-by: Ma Yukun <68433685+TheSkyC@users.noreply.github.com>
2026-04-06 18:23:08 +03:00
Miss Islington (bot)
64207c930b
[3.14] gh-145883: Fix two heap-buffer-overflows in _zoneinfo (GH-145885) (#148087)
(cherry picked from commit fe9befc1ca)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-04 17:13:13 +01:00
sunmy2019
b406d85603
[3.14] gh-146615: Fix format specifiers in extension modules (GH-146617) (#147704)
Fix format specifier in parse_task_name() for long result.
2026-04-01 15:12:44 +02:00
Miss Islington (bot)
25b48b84b8
[3.14] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (GH-145901) (#147331)
gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (GH-145901)

The long_from_string_base() might return a small integer, when the
_pylong.py is used to do conversion.  Hence, we must be careful here to
not smash it "small int" bit by using the _PyLong_FlipSign().
(cherry picked from commit db5936c5b8)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-31 16:14:12 +02:00
Serhiy Storchaka
58c7259133
[3.14] gh-146615: Fix format specifiers in extension modules (GH-146617) (GH-146652)
(cherry picked from commit 1c396e1821)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-03-31 10:07:09 +00:00
Miss Islington (bot)
3866c2947b
[3.14] gh-146615: Fix format specifiers in test cextensions (GH-146618) (GH-146649)
(cherry picked from commit b7055533ab)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-03-31 08:31:05 +00:00
Miss Islington (bot)
de234fc07a
[3.14] gh-146579: _zstd: Fix decompression options dict error message (GH-146577) (#146611)
The TypeError in _zstd_set_d_parameters incorrectly referred to
compression options; say decompression options instead.
(cherry picked from commit 4d0e8ee649)

Co-authored-by: cui <cuiweixie@gmail.com>
2026-03-30 08:26:45 +00:00
Miss Islington (bot)
36c22d06f0
[3.14] gh-146083: Upgrade bundled Expat to 2.7.5 (GH-146085) (#146603)
(cherry picked from commit e39d84a37d)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-03-29 17:31:02 +00:00
Miss Islington (bot)
1458ea0065
[3.14] gh-146090: fix memory management of internal sqlite3 callback contexts (GH-146569) (#146595)
gh-146090: fix memory management of internal `sqlite3` callback contexts (GH-146569)
(cherry picked from commit aa6680775d)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-03-29 15:15:05 +02:00
Bénédikt Tran
883b6d22d1
[3.14] gh-146080: fix a crash in SNI callbacks when the SSL object is gone (GH-146573) (#146597)
(cherry picked from commit 24db78c532)
2026-03-29 12:58:37 +00:00