Commit graph

5515 commits

Author SHA1 Message Date
Mikhail Efimov
4504ff89d5
[3.13] gh-140373: Correctly emit PY_UNWIND event when generator is closed (GH-140767) (#140821) 2025-12-20 16:21:11 +02:00
Sam Gross
85f48038aa
[3.13] gh-142342: Fix m68k assembler operand constraints for %fpcr access (gh-142343) (#142459)
On m68k, an fmove instruction accessing %fpcr may only move from
or to a data register or a memory operand. The constraint "g" also
permits the use of address registers, which is invalid. The correct
constraint is "dm". Beginning with GCC 15, the register allocator
picks an address register in the code which causes SIGILL during
runtime.
(cherry picked from commit 02c085d48b)

Co-authored-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Co-authored-by: Michael Karcher <github@mkarcher.dialup.fu-berlin.de>
2025-12-09 14:13:35 +00:00
dr-carlos
d768900ca4
[3.13] gh-141732: Fix ExceptionGroup repr changing when original exception sequence is mutated (GH-141736) (#142391)
* [3.13] gh-141732: Fix `ExceptionGroup` repr changing when original exception sequence is mutated (GH-141736)
(cherry picked from commit ff2577f56e)

Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
2025-12-08 18:46:55 +00:00
Thomas Wouters
10d1e9369a Post 3.13.11 2025-12-05 20:43:39 +01:00
Thomas Wouters
627894459a Python 3.13.11 2025-12-05 17:06:33 +01:00
Serhiy Storchaka
93d5c481af
[3.13] gh-141370: Fix undefined behavior when using Py_ABS() (GH-141548) (#142304)
(cherry picked from commit 706fdda8b3)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-12-05 15:52:12 +00:00
Thomas Wouters
fedefc5f3a Post 3.13.10 2025-12-02 17:41:30 +01:00
Thomas Wouters
4fd884356d Python 3.13.10 2025-12-02 13:49:50 +01:00
Victor Stinner
80b752285d
[3.13] gh-116008: Detect freed thread state in faulthandler (#141988) (#142017)
gh-116008: Detect freed thread state in faulthandler (#141988)

Add _PyMem_IsULongFreed() function.

(cherry picked from commit d5d9e89dde)
2025-11-27 17:55:31 +01:00
Victor Stinner
43882c7c4e
[3.13] gh-140815: Fix faulthandler for invalid/freed frame (#140921) (#140985)
gh-140815: Fix faulthandler for invalid/freed frame (#140921)

faulthandler now detects if a frame or a code object is invalid or
freed.

Add helper functions:

* _PyCode_SafeAddr2Line()
* _PyFrame_SafeGetCode()
* _PyFrame_SafeGetLasti()

_PyMem_IsPtrFreed() now detects pointers in [-0xff, 0xff] range
as freed.

(cherry picked from commit a84181c31b)
2025-11-05 18:39:28 +01:00
Sebastian Pipping
bc36bd1786
[3.13] gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (GH-139234) (#139367)
* gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (#139234)

Expose the XML Expat 2.7.2 mitigation APIs to disallow use of
disproportional amounts of dynamic memory from within an Expat
parser (see CVE-2025-59375 for instance).

The exposed APIs are available on Expat parsers, that is,
parsers created by `xml.parsers.expat.ParserCreate()`, as:

- `parser.SetAllocTrackerActivationThreshold(threshold)`, and
- `parser.SetAllocTrackerMaximumAmplification(max_factor)`.

(cherry picked from commit f04bea44c3)
(cherry picked from commit 68a1778b77)
2025-11-02 12:39:11 +00:00
Victor Stinner
ec5f5418f9
[3.13] gh-140487: Fix Py_RETURN_NOTIMPLEMENTED in limited C API 3.11 (GH-140636) (GH-140670)
Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE have already been
fixed by commit 9258f3da91 (issue gh-134989).

(cherry picked from commit c636477523)
2025-10-27 14:43:59 +01:00
Thomas Wouters
115ee7ba5c Post 3.13.9 2025-10-14 20:35:49 +02:00
Thomas Wouters
e40f1619ec Python 3.13.9
-----BEGIN PGP SIGNATURE-----
 
 iQKTBAABCgB9FiEEcWlgX2LHUTVtBUomqCHmgOX6YwUFAmjuVaJfFIAAAAAALgAo
 aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDcx
 Njk2MDVGNjJDNzUxMzU2RDA1NEEyNkE4MjFFNjgwRTVGQTYzMDUACgkQqCHmgOX6
 YwXJow//cfFrVV9JbaBvZhMPnVAdjPfLd1sskCzTEvM/SkNmUqqmjUGh6TgCf9uZ
 ujSDe8sZ+ihDSPMFEWg7uQQULn2qKioCvGptVMHIWIKaWjutb3qZJBfXKIFxpvr4
 jZyLnRsTVQZ3RllPGjlb0WzBrazmCLmVOsZyHCAmRpeSPPE77KJXn9dsz5PlA+KH
 8n2LsvuG2hqF46NBZu0ro43d6rX16TrBI7CGMZQMTMkDGe75vIQrhk/2Ek66UZtA
 6Y5grca1vsnSEPNaVXLKpC+Ndosf6ziI23YLoAnsE8q15lEsEwAiS8Rx2rqiWVgb
 MwrUccveyiqm5/bv0v+MHXOXzuipEchR/YfdyJPBm1JyeOEvYX+Zsp0sMe5nVIV8
 WHWgnrb0A0pIbCLL5LqoPdCrksOq23NYkE/ayvHmaOhFsQ62vedts/RFLpnyPlVl
 9iY/XE098MUvngsDkkCVqNwkZNYWymqnDRm2hqPWNqQlDSCPGhpR4dcPLr0FW8Ji
 iJUdYJ0Q5h6YJOMLZyfRkqlPUxay7PSw6+PjaKyHChpAAPlhqPqjsYcLSjxRJ3QX
 R5A7V1gavRV0opHnQzDoQxMacjmCA3ELnAXqBly8YyjOB+OuRg5UP1xDlwYkaHF4
 mwMMw731XM98MXphu4Q0PW594TQplLbDsdpmcWimFtAJu2NVW4U=
 =hm/l
 -----END PGP SIGNATURE-----

Python 3.13.9
2025-10-14 20:33:45 +02:00
Serhiy Storchaka
92f7965cf6
[3.13] gh-139640: Fix swallowing syntax warnings in different modules (GH-139755) (GH-140119)
Revert GH-131993.

Fix swallowing some syntax warnings in different modules if they accidentally
have the same message and are emitted from the same line.

Fix duplicated warnings in the "finally" block.

(cherry picked from commit 279db6bede)
2025-10-14 15:46:11 +00:00
Thomas Wouters
8183fa5e3f Python 3.13.9 2025-10-14 15:52:31 +02:00
Sam Gross
16d2e97cf3
[3.13] gh-137400: Fix thread-safety issues when profiling all threads (gh-137518) (gh-137733)
There were a few thread-safety issues when profiling or tracing all
threads via PyEval_SetProfileAllThreads or PyEval_SetTraceAllThreads:

* The loop over thread states could crash if a thread exits concurrently
  (in both the free threading and default build)
* The modification of `c_profilefunc` and `c_tracefunc` wasn't
  thread-safe on the free threading build.
(cherry picked from commit a10152f8fd)
2025-10-09 11:42:47 -04:00
Thomas Wouters
527623e827 Post 3.13.8 2025-10-07 16:04:40 +02:00
Thomas Wouters
a15ae614de Python 3.13.8 2025-10-07 14:01:51 +02:00
Eloisa Perez-Bennetts
5775c0037b
[3.13] Revert "gh-136006: fix Py_NAN expansion on Solaris systems (GH-136575) (#138734)" (#139239)
This reverts commit df349036b3 as discussed in https://github.com/python/cpython/pull/138733#issuecomment-3317818806
2025-09-22 14:18:11 +00:00
Bénédikt Tran
df349036b3
[3.13] gh-136006: fix Py_NAN expansion on Solaris systems (GH-136575) (#138734)
On Solaris, `Py_NAN` may expand as a function address instead of a floating-point number.
This amends commit 7a3b03509e.
(cherry picked from commit d54b1091d4)
2025-09-18 12:47:12 +01:00
Kliment Lamonov
ebccd1de88
[3.13] gh-132744: Check recursion limit in _PY_FRAME_GENERAL (GH-132746) (GH-138032) 2025-08-22 20:25:24 +08:00
Gregory P. Smith
9face218e7
[3.13] gh-87135: Hang non-main threads that attempt to acquire the GIL during finalization (GH-105805) (GH-137827)
* [3.13] gh-87135: Hang non-main threads that attempt to acquire the GIL during finalization (GH-105805)

Instead of surprise crashes and memory corruption, we now hang threads that attempt to re-enter the Python interpreter after Python runtime finalization has started. These are typically daemon threads (our long standing mis-feature) but could also be threads spawned by extension modules that then try to call into Python. This marks the `PyThread_exit_thread` public C API as deprecated as there is no plausible safe way to accomplish that on any supported platform in the face of things like C++ code with finalizers anywhere on a thread's stack. Doing this was the least bad option.

(cherry picked from commit 8cc5aa47ee)

Co-authored-by: Jeremy Maitin-Shepard <jeremy@jeremyms.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>

* state "3.13.7 and earlier"
* backport: do not add the deprecated marker
* fix Py_IsFinalizing doc ref

---------

Co-authored-by: Jeremy Maitin-Shepard <jeremy@jeremyms.com>
2025-08-17 09:08:14 -07:00
Thomas Wouters
470091376e Post 3.13.7 2025-08-14 20:13:25 +02:00
Thomas Wouters
bcee1c3221 Python 3.13.7 2025-08-14 13:12:11 +02:00
Thomas Wouters
b00a9bd8dc Post 3.13.6 2025-08-06 23:04:32 +02:00
Thomas Wouters
4e66535108 Python 3.13.6 2025-08-06 15:05:20 +02:00
Miss Islington (bot)
1bb2ae503b
[3.13] gh-136823: Update documentation on excluded headers in Python.h (GH-136824) (#137438)
Co-authored-by: Sina Zel taat <111974143+SZeltaat@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-08-05 22:16:24 +01:00
Brian Schubert
d29a9c55cf
[3.13] Doc: fix duplicated words (GH-136086) (#137357)
(cherry picked from commit 698bab5a40)

Co-authored-by: Weilin Du <108666168+LamentXU123@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-08-04 06:41:47 +08:00
Neil Schemenauer
5c16f699d2
[3.13] GH-133136: Revise QSBR to reduce excess memory held (gh-135473) (gh-136480)
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-30 11:06:44 -07:00
Kumar Aditya
3f57d9be8b
[3.13] gh-136759: revert rename lock.h to pylock.h (GH-137041) (#137075) (#137166)
Revert "[3.13] gh-136759: rename `lock.h` to `pylock.h` (GH-137041) (#137075)"

This reverts commit 74503acba7.
2025-07-28 12:19:32 +00:00
AN Long
74503acba7
[3.13] gh-136759: rename lock.h to pylock.h (GH-137041) (#137075)
Rename `lock.h` to `pylock.h` to avoid conflicts with headers of other projects.
(cherry picked from commit ec02db5caa)
2025-07-24 21:36:25 +05:30
Victor Stinner
e3a277c8d8
[3.13] gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614) (#136126)
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-07-01 11:26:52 +02:00
Mikhail Efimov
e753a7c5f0
[3.13] gh-125723: Fix crash with f_locals when generator frame outlive their generator (GH-135453)
Backport of 8e20e42cc6 from GH-126956

Closes GH-125723
2025-06-14 04:08:03 +10:00
Thomas Wouters
8d07562849 Post 3.13.5 2025-06-11 23:32:50 +02:00
Thomas Wouters
6cb20a219a Python 3.13.5 2025-06-11 17:36:57 +02:00
Victor Stinner
922dc2ccb0
[3.13] gh-134989: Fix Py_RETURN_NONE in the limited C API (GH-135165) (#135182)
gh-134989: Fix Py_RETURN_NONE in the limited C API (GH-135165)

Fix Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE macros in the
limited C API 3.11 and older:
Don't treat Py_None, Py_True and Py_False as immortal.

(cherry picked from commit 9258f3da91)
2025-06-05 15:02:09 +00:00
Victor Stinner
95f62969bb
[3.13] gh-134989: Implement PyObject_DelAttr() as a macro in the limited C API (GH-135021) (#135134)
gh-134989: Implement PyObject_DelAttr() as a macro in the limited C API (GH-135021)

(cherry picked from commit c21113072c)
2025-06-04 17:10:51 +02:00
Victor Stinner
659631f769
[3.13] gh-133256: Add _Py_NONSTRING macro (#133257) (#135135)
gh-133256: Add _Py_NONSTRING macro (#133257)

Fix GCC 15 compiler warnings such as:

    In file included from Python/pylifecycle.c:26:
    Include/internal/pycore_runtime.h:47:26: warning:
    initializer-string for array of 'char' truncates NUL terminator
    but destination lacks 'nonstring' attribute (9 chars into 8
    available) [-Wunterminated-string-initialization]
       47 | #define _Py_Debug_Cookie "xdebugpy"
          |                          ^~~~~~~~~~

(cherry picked from commit e26bafd107)
2025-06-04 17:10:35 +02:00
Thomas Wouters
c7ee596fd0 Post 3.13.4 2025-06-03 22:22:30 +02:00
Thomas Wouters
8a526ec7cb Python 3.13.4 2025-06-03 17:34:24 +02:00
Miss Islington (bot)
b0c9c192f1
[3.13] gh-134875: Fix mimallc build error for the old compilers (gh-134994) (gh-135054)
gh-134875: Fix mimallc build error for the old compilers (gh-134994)
(cherry picked from commit b525e31b7f)

Co-authored-by: Donghee Na <donghee.na@python.org>
2025-06-03 17:04:20 +09:00
Miss Islington (bot)
bad9f63f6c
[3.13] gh-129748: Update mimalloc to use atomic store for mi_block_set_nextx (GH-134238) (gh-134353)
gh-129748: Update mimalloc to use atomic store for mi_block_set_nextx (GH-134238)
(cherry picked from commit 317c496223)

Co-authored-by: Donghee Na <donghee.na@python.org>
2025-05-20 16:26:23 +00:00
Serhiy Storchaka
6279eb8c07
[3.13] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944)
If the error handler is used, a new bytes object is created to set as
the object attribute of UnicodeDecodeError, and that bytes object then
replaces the original data. A pointer to the decoded data will became invalid
after destroying that temporary bytes object. So we need other way to return
the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal().

_PyBytes_DecodeEscape() does not have such issue, because it does not
use the error handlers registry, but it should be changed for compatibility
with _PyUnicode_DecodeUnicodeEscapeInternal().
(cherry picked from commit 9f69a58623)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-20 14:46:57 +02:00
Serhiy Storchaka
3c9d1778ef
[3.13] bpo-44172: Keep reference to original window in curses subwindow objects (GH-26226) (GH-133370)
The X/Open curses specification[0] and ncurses documentation[1]
both state that subwindows must be deleted before the main window.

Deleting the windows in the wrong order causes a double-free with
NetBSD's curses implementation.

To fix this, keep track of the original window object in the subwindow
object, and keep a reference to the original for the lifetime of
the subwindow.

[0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/delwin.html
[1] https://invisible-island.net/ncurses/man/curs_window.3x.html
(cherry picked from commit 0af61fe2f4)

Co-authored-by: Michael Forney <mforney@mforney.org>
2025-05-04 11:15:43 +00:00
Donghee Na
7ffef8d07b
[3.13] gh-132070: Use _PyObject_IsUniquelyReferenced in unicodeobject (gh-133039) (gh-133126)
* gh-132070: Use _PyObject_IsUniquelyReferenced in unicodeobject (gh-133039)

---------
(cherry picked from commit 75cbb8d89e)

Co-authored-by: Donghee Na <donghee.na@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

* Add _PyObject_IsUniquelyReferenced

---------

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-04-29 14:26:44 +09:00
Tomas R.
4ff5d88fb1
[3.13] gh-131927: Prevent emitting compiler warnings twice (GH-131993) (GH-132463)
(cherry picked from commit 3d08c8ad20)
2025-04-13 08:42:04 +00:00
Thomas Wouters
5f238c6ad2 Post 3.13.3 2025-04-08 19:19:59 +02:00
Thomas Wouters
6280bb5478 Python 3.13.3 2025-04-08 15:54:08 +02:00
Mark Shannon
3f3863281b
[3.13] GH-127953: Make line number lookup O(1) regardless of the size of the code object (#129127)
GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-128350)
2025-04-07 20:15:02 +02:00