15206 Commits

Author SHA1 Message Date
Miss Islington (bot)
237467f474
[3.14] gh-144100: Fix crash for POINTER(str) used in ctypes argtypes (GH-144108) (#144244)
gh-144100: Fix crash for POINTER(str) used in ctypes argtypes (GH-144108)
(cherry picked from commit 8f459255eba2b6639f1912e5c5e318a7cdafada1)

Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-01-26 12:53:20 +00:00
Stan Ulbrych
fbc81558a4
[3.14] gh-144023: Prevent follow_symlinks from being allowed with an fd of 0 (GH-144022) (#144151)
[3.14] gh-144023: Prevent follow_symlinks from being allowed with an fd of 0 (GH-144022)

The check was (fd > 0), should be (fd >= 0).
(cherry picked from commit fa44efa0ef1972ac1e2f66996303154be11f605e)

Co-authored-by: AZero13 <gfunni234@gmail.com>
2026-01-22 15:53:02 +00:00
Miss Islington (bot)
1cfb4192fe
[3.14] Update struct.__doc__: _Bool available unconditionally (GH-143716) (#144070)
Update struct.__doc__: _Bool available unconditionally (GH-143716)

This amends commit a9296e7f3be4d6c22271b25c86467ff867c63bbb.
(cherry picked from commit 31c81ab0a2fb7009a76426617991a9b539ab0180)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-01-20 12:33:28 +00:00
Miss Islington (bot)
6219497fd9
[3.14] gh-143674: Document F/D complex format characters in struct module (GH-143675) (#143918)
gh-143674: Document F/D complex format characters in struct module (GH-143675)

Add documentation for the F (complex from two floats) and D (complex
from two doubles) format characters in the struct module docstring.
These format characters were implemented but not documented.
(cherry picked from commit 3e932257980be8907698c378c23026e262ba066c)

Co-authored-by: Muneeb Ullah <moneebullah25@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-01-16 17:38:08 +00:00
Sam Gross
0042384bd5
[3.14] gh-143880: Fix data race in functools.partial in free threading build (#143882)
gh-143880: Fix data race in `functools.partial` in free threading build

The assignment to `pto->vectorcall` isn't thread-safe in the free
threading build. Note that this is already fixed in the main branch.
2026-01-16 22:25:40 +05:30
Miss Islington (bot)
4a191f9e70
[3.14] gh-143249: Fix buffer leak when overlapped operation fails to start on windows (GH-143250) (#143795)
gh-143249: Fix buffer leak when overlapped operation fails to start on windows (GH-143250)
(cherry picked from commit 103a384bfdeafc68ab39ea9bf8838a8b2eec83dd)

Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
2026-01-13 13:57:54 +00:00
Miss Islington (bot)
7a066ad020
[3.14] gh-143196: Fix crash in non-standard use of internal JSON encoder object (GH-143618) (GH-143748)
The internal encoder object returned by undocumented function
json.encoder.c_make_encoder() (aka _json.make_encoder()) crashed
when it was called with non-zero second argument.
(cherry picked from commit c559135c931789ebc752ae68814858c398cb798b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-01-12 18:50:40 +00:00
Miss Islington (bot)
78ea9eb340 [3.14] gh-143544: Fix possible use-after-free in the JSON decoder when JSONDecodeError disappears during raising it (GH-143561) (#143733)
gh-143544: Fix possible use-after-free in the JSON decoder when JSONDecodeError disappears during raising it (GH-143561)
(cherry picked from commit c3157480601499565fd42a8afbdb0207328ac484)

Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-01-12 16:06:24 +00:00
Miss Islington (bot)
8f85adc151
[3.14] gh-78724: Raise RuntimeError's when calling methods on non-ready Struct()'s (GH-143643) (GH-143695)
(cherry picked from commit 515ae4078dffa0b74e5e5431462c2f4fe4563ffa)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-01-12 14:45:07 +02:00
Miss Islington (bot)
73d44452a2
[3.14] gh-142881: Fix concurrent and reentrant call of atexit.unregister() (GH-142901) (GH-143721)
(cherry picked from commit dbd10a6c29ba1cfc9348924a090b5dc514470002)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-01-12 11:44:12 +02:00
Serhiy Storchaka
115b27d2bb
[3.14] gh-143638: Forbid cuncurrent use of the Pickler and Unpickler objects in C implementation (GH-143664) (GH-143686)
Previously, this could cause crash or data corruption, now concurrent calls
of methods of the same object raise RuntimeError.
(cherry picked from commit d1282efb2b847bf9274d78c5f15ea00499b2c894)
2026-01-11 12:37:00 +00:00
Miss Islington (bot)
0e2ed4b0e1
[3.14] gh-143191: Use _PyOS_MIN_STACK_SIZE in _thread.stack_size() (GH-143601) (#143611)
gh-143191: Use _PyOS_MIN_STACK_SIZE in _thread.stack_size() (GH-143601)

The stack size must be at least _PyOS_MIN_STACK_SIZE+SYSTEM_PAGE_SIZE
bytes.
(cherry picked from commit ba10100c3931b18812b82d7124e2238f01927910)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-01-09 15:34:39 +00:00
Miss Islington (bot)
f264f103d4
[3.14] gh-143378: Fix use-after-free when BytesIO is concurrently mutated during write operations (GH-143408) (GH-143599)
PyObject_GetBuffer() can execute user code (e.g. via __buffer__), which may
close or otherwise mutate a BytesIO object while write() or writelines()
is in progress. This could invalidate the internal buffer and lead to a
use-after-free.

Ensure that PyObject_GetBuffer() is called before validation checks.
(cherry picked from commit 6d54b6ac7d5744e1f59d784c8e020d632d2959a3)

Co-authored-by: zhong <60600792+superboy-zjc@users.noreply.github.com>
2026-01-09 12:16:51 +00:00
Miss Islington (bot)
a299c1b185
[3.14] gh-143429: Use compile-time NaN encoding detection for test_struct (GH-143432) (#143595)
gh-143429: Use compile-time NaN encoding detection for test_struct (GH-143432)
(cherry picked from commit dcdb23f9db2bd683e5d37558f09b458be25a9b4d)

Co-authored-by: Henry Chen <chenx97@aosc.io>
2026-01-09 12:32:49 +01:00
Miss Islington (bot)
fcd9500c53
[3.14] gh-142991: socketmodule: fixed getsockaddrlen() for PF_DIVERT socket (GH-142993) (#143481)
gh-142991: socketmodule: fixed getsockaddrlen() for PF_DIVERT socket (GH-142993)
(cherry picked from commit 05406b221dc9d5946c60253392788d60f1f08c8b)

Co-authored-by: Gleb Smirnoff <glebius@FreeBSD.org>
2026-01-07 14:20:07 +00:00
Semyon Moroz
8b72c3d561
[3.14] gh-143331: Schedule to remove format "N" for Decimal (GH-143372) (#143476)
(cherry picked from commit dd750b348501247d458ea8d454213d4959a8f8b9)
2026-01-06 15:58:29 +02:00
Miss Islington (bot)
623dbafc9d
[3.14] gh-143309: fix UAF in os.execve when the environment is concurrently mutated (GH-143314) (#143398)
gh-143309: fix UAF in `os.execve` when the environment is concurrently mutated (GH-143314)
(cherry picked from commit 9609574e7fd36edfaa8b575558a82cc14e65bfbc)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-01-03 22:31:45 +00:00
Miss Islington (bot)
c99d87db1f
[3.14] gh-143308: fix UAF when PickleBuffer is concurrently mutated in a callback (GH-143312) (#143396)
gh-143308: fix UAF when PickleBuffer is concurrently mutated in a callback (GH-143312)
(cherry picked from commit 6c53af18f61c074d514e677b469b6201573a59da)

---------------

Co-authored-by: Aaron Wieczorek <aaronw@fastmail.com>
Co-authored-by: Aaron Wieczorek <woz@Aarons-MacBook-Pro.local>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-01-03 22:27:35 +00:00
Miss Islington (bot)
8beec4a2e4
[3.14] gh-143310: fix crash in Tcl object conversion with concurrent mutations (GH-143321) (#143343)
gh-143310: fix crash in Tcl object conversion with concurrent mutations (GH-143321)
(cherry picked from commit 9712dc1d9eb03ffa96ed746d20bd43239d251ba7)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-01-02 10:17:13 +00:00
Bénédikt Tran
048edac8be
[3.14] gh-142830: prevent some crashes when mutating sqlite3 callbacks (GH-143245) (#143322)
(cherry picked from commit 7f6c16a956d598663d8c67071c492f197045d967)
2026-01-01 11:24:21 +00:00
Miss Islington (bot)
7ff87fa8e1
[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)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-12-29 17:57:54 +00:00
Miss Islington (bot)
723ed8c507
[3.14] gh-143164: Fix incorrect error message for ctypes bitfield overflow (GH-143165) (GH-143176)
(cherry picked from commit b9a48064306229287d7211e9510f578065e457fc)

Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
2025-12-25 17:34:02 +00:00
Miss Islington (bot)
88a4d0d34b
[3.14] gh-143145: Fix possible reference leak in ctypes _build_result() (GH-143131) (GH-143169)
The result tuple was leaked if __ctypes_from_outparam__() failed for any item.
(cherry picked from commit 579c5b496b467a2b175cb30caa4f6873cb13c9a1)

Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
2025-12-25 19:09:53 +02:00
Miss Islington (bot)
240ee20770
[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)

Co-authored-by: kaushal trivedi <155625932+Kaushalt2004@users.noreply.github.com>
2025-12-25 13:41:10 +02:00
Miss Islington (bot)
aee8c217bd
[3.14] gh-122431: Correct the non-negative error message in readline.append_history_file (GH-143075) (GH-143090)
gh-122431: Correct the non-negative error message in `readline.append_history_file` (GH-143075)

"positive" -> "non-negative", since zero is included.
(cherry picked from commit a273bc99d2ff853f59ee6da4d897b1be72a03975)

Co-authored-by: Zheng Yu <dataisland@outlook.com>
2025-12-23 05:01:41 +00:00
Miss Islington (bot)
586047a8d8
[3.14] gh-143012: use Py_ssize_t cast for PyBytes_FromStringAndSize (GH-143013) (#143014)
gh-143012: use `Py_ssize_t` cast for `PyBytes_FromStringAndSize` (GH-143013)
(cherry picked from commit 5989095dfd08735525f2b615066bc3c231b09388)

Co-authored-by: AZero13 <gfunni234@gmail.com>
2025-12-20 08:02:44 +00:00
Miss Islington (bot)
8c92d665ee
[3.14] gh-112127: Fix possible use-after-free in atexit.unregister() (GH-114092) (#142878)
gh-112127: Fix possible use-after-free in atexit.unregister() (GH-114092)
(cherry picked from commit 2b466c47c333106dc9522ab77898e6972e25a2c6)

Co-authored-by: Benjamin Johnson <ben332004@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-12-17 21:36:12 +05:30
Miss Islington (bot)
897e2b46fb
[3.14] gh-142783: Fix possible use after free in zoneinfo module (GH-142790) (GH-142862)
(cherry picked from commit 8307a14d0edc14ae2f775995720e4b6d6dc865b3)

Co-authored-by: wangxiaolei <fatelei@gmail.com>
2025-12-17 09:23:59 +00:00
Miss Islington (bot)
d089cad656
[3.14] gh-142495: Make defaultdict keep existed value when racing with __missing__ (GH-142668) (GH-142832)
(cherry picked from commit a0434075108efe6acdfba34f42545f4d80ac9a5e)

Co-authored-by: Edward Xu <xuxiangad@gmail.com>
2025-12-16 15:31:05 +00:00
Miss Islington (bot)
c31ea74970
[3.14] gh-142595: Amend be5e0dcdedb (fix NULL pointer dereference) (GH-142775) (#142788)
gh-142595: Amend be5e0dcdedb (fix NULL pointer dereference) (GH-142775)
(cherry picked from commit 15a9762500b3d9a13206aa54d8695513efaf3b55)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-12-16 15:42:43 +05:30
Cody Maloney
58da2a9d94
[3.14] gh-142594: fix by property calls io.TextIOWrapper.detach (GH-142706) (GH-142755)
(cherry picked from commit 1d3854a19a376c1fc7f71e96c620f6bc2de8cd74)

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: yihong <zouzou0208@gmail.com>
2025-12-16 10:55:25 +01:00
Miss Islington (bot)
575174ee78
[3.14] gh-142595: add type check for namedtuple call during decimal initialization (GH-142608) (GH-142623)
(cherry picked from commit be5e0dcdedb63185aaa3e2f711d14dc828cb3640)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-12-15 15:03:57 +01:00
Neil Schemenauer
27f27a68b3
[3.14] gh-142531: Fix free-threaded GC performance regression (gh-142562) (gh-142617)
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)
2025-12-12 14:30:20 -08:00
Sam Gross
12d2b95adf
[3.14] gh-142589: Fix PyUnstable_Object_IsUniqueReferencedTemporary (gh-142593) (#142597)
PyUnstable_Object_IsUniqueReferencedTemporary wasn't handling tagged
ints on the evaluation stack properly.
(cherry picked from commit a26c831bc486b6e607cee6a5923bad52b97c2341)
2025-12-11 20:08:45 +00:00
Petr Viktorin
e09c4deb25
[3.14] gh-123241: Don't modify ref count during visitation (GH-142232) (#142567)
(cherry picked from commit da8199f8842c2830fa4015138725849863523de4)

Co-authored-by: Dino Viehland <dinoviehland@meta.com>
2025-12-11 10:51:11 -08:00
Miss Islington (bot)
fc40e7dc52
[3.14] Fix os.posix_spawn() error handling (GH-142532) (#142582)
Fix os.posix_spawn() error handling (GH-142532)

Consistently use `goto exit;` in `py_posix_spawn()`.
(cherry picked from commit 8cfa351560487d472df4c7d841814801fbf57397)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2025-12-11 17:32:11 +00:00
Miss Islington (bot)
7218be0199
[3.14] gh-142556: fix crash when a task gets re-registered during finalization in asyncio (GH-142565) (#142566)
gh-142556: fix crash when a task gets re-registered during finalization in `asyncio` (GH-142565)
(cherry picked from commit 42d2bedb875f42f0580ee2cfb4bd80a5a229bbd4)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-12-11 10:00:44 +00:00
Miss Islington (bot)
94012d65c9
[3.14] gh-116738: Statically initialize special constants in cmath module (gh-142161) (gh-142261)
The initialization during `mod_exec` wasn't thread-safe with multiple interpreters.
(cherry picked from commit 2dac9e6016c81abbefa4256253ff5c59b29378a7)

Co-authored-by: Alper <alperyoney@fb.com>
2025-12-04 14:51:55 +00:00
Miss Islington (bot)
212b096b2a
[3.14] gh-140042: Removing unsafe call to sqlite3_shutdown (GH-141690) (#141793)
Co-authored-by: Prithviraj Chaudhuri <p.chaudhuri1993@gmail.com>
2025-11-30 14:32:11 +02:00
Miss Islington (bot)
f47e928574
[3.14] gh-116738: Fix thread-safety issue in re module for free threading (gh-141923) (gh-141990)
Added atomic operations to `scanner_begin()` and `scanner_end()` to prevent
race conditions on the `executing` flag in free-threaded builds. Also added
tests for concurrent usage of the `re` module.

Without the atomic operations, `test_scanner_concurrent_access()` triggers
`assert(self->executing)` failures, or a thread sanitizer run emits errors.
(cherry picked from commit bc9e63dd9d2931771415cca1b0ed774471d523c0)

Co-authored-by: Alper <alperyoney@fb.com>
2025-11-26 21:08:39 +00:00
Petr Viktorin
32a38a2523
[3.14] gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (GH-139668) (#141661)
Co-authored-by: Rok Mandeljc <rok.mandeljc@gmail.com>
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-25 14:21:53 +01:00
Stefano Rivera
394db662a5
[3.14] GH-139914: Handle stack growth direction on HPPA (GH-140028) (#141404)
* [3.14] GH-139914: Handle stack growth direction on HPPA (GH-140028)

Adapted from a patch for Python 3.14 submitted to the Debian BTS by John David Anglin https://bugs.debian.org/1105111#20

* Forgot to update test_call

* WTF typo
2025-11-23 15:55:33 -08:00
Miss Islington (bot)
972aa93692
[3.14] gh-141801: Use accessors for ASN1_STRING fields in libssl (GH-141802) (#141847)
gh-141801: Use accessors for ASN1_STRING fields in libssl (GH-141802)

* gh-141801: Use accessors for ASN1_STRING fields

While ASN1_STRING is currently exposed, it is better to use the
accessors. See https://github.com/openssl/openssl/issues/29117 where, if
the type were opaque, OpenSSL's X509 objects could be much more
memory-efficient.

* Update Modules/_ssl.c



* Update Modules/_ssl.c



---------
(cherry picked from commit c41fce08a5d7aae8fd9e3fa25e0ba521600e097c)

Co-authored-by: David Benjamin <davidben@davidben.net>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-22 10:53:06 -08:00
Miss Islington (bot)
af586d8d26
[3.14] gh-116738: Make csv module thread-safe (gh-141365) (gh-141825)
Added a critical section to protect the states of `ReaderObj` and `WriterObj` in the free-threading build. Without the critical sections, both new free-threading tests were crashing.
(cherry picked from commit fb26d9c2ef739cbfdc134da5ab89470511f1f5fd)

Co-authored-by: Alper <alperyoney@fb.com>
2025-11-21 16:47:13 +00:00
Victor Stinner
5398d088f4
[3.14] gh-141784: Fix _remote_debugging_module.c compilation on 32-bit Linux (#141796) (#141800)
gh-141784: Fix _remote_debugging_module.c compilation on 32-bit Linux (#141796)

Include Python.h before system headers to make sure that
_remote_debugging_module.c uses the same types (ABI) than Python.

(cherry picked from commit 722f4bb8c9c6b32a7221e4813058cbb5c3989c10)
2025-11-20 18:13:03 +01:00
Miss Islington (bot)
7cb15f93fe
[3.14] gh-141659: Fix bad file descriptor error in subprocess on AIX (GH-141660) (GH-141738)
/proc/self does not exist on AIX.
(cherry picked from commit 92c5de73b8d7526326c865b1a669b868f0d40c1e)

Co-authored-by: Ayappan Perumal <ayappap2@in.ibm.com>
2025-11-19 08:05:01 +00:00
Gregory P. Smith
0d8fb0b852
[3.14] gh-137109: refactor warning about threads when forking (GH-141438) (GH-141614)
This splits the OS API specific functionality to get the number of threads out
from the fallback Python method and warning raising code itself.  This way the
OS APIs can be queried before we've run
`os.register_at_fork(after_in_parent=...)` registered functions which
themselves may (re)start threads that would otherwise be detected.

This is best effort.  If the OS APIs are either unavailable or fail, the
warning generating code still falls back to looking at the Python threading
state after the CPython interpreter world has been restarted and the
after_in_parent calls have been made.  The common case for most Linux and macOS
environments should work today.

This also lines up with the existing TODO refactoring, we may choose to expose
this API to get the number of OS threads in the `os` module in the future.

Note: This is a simplified backport that maintains the void return type
for warn_about_fork_with_threads() and keeps PyErr_Clear() in the warning path,
as the error handling changes from fd8f42d3d1 are not needed in 3.14.
2025-11-16 19:45:29 +00:00
Miss Islington (bot)
1cde019ecd
[3.14] gh-114203: skip locking if object is already locked by two-mutex critical section (GH-141476) (#141564)
gh-114203: skip locking if object is already locked by two-mutex critical section (GH-141476)
(cherry picked from commit f26ed455d5582a7d66618acf2a93bc4b22a84b47)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-11-14 18:38:30 +00:00
Miss Islington (bot)
79195df23c
[3.14] gh-140260: fix data race in _struct module initialization with subinterpreters (GH-140909) (#141501)
gh-140260: fix data race in `_struct` module initialization with subinterpreters (GH-140909)
(cherry picked from commit 63548b36998e7f7cd5c7c28b53b348a93f836737)

Co-authored-by: Shamil <ashm.tech@proton.me>
2025-11-13 17:23:22 +05:30
Miss Islington (bot)
0b44bc3379
[3.14] gh-124111: Fix TCL 9 thread detection (GH-141482)
(cherry picked from commit dc0987080ed66c662e8e0b24cdb8c179817bd697)

Co-authored-by: Michael Cho <michael@michaelcho.dev>
2025-11-12 22:43:31 +00:00