5544 Commits
Author SHA1 Message Date
Thomas Wouters 42155a0fea Post 3.13.18 2026-10-25 20:35:10 +01:00
Thomas Wouters 0d4bd512fc Python 3.13.18 2026-10-25 19:31:23 +01:00
Thomas Wouters a737e40512 Post 3.13.17 2026-10-21 17:53:33 +02:00
Thomas Wouters 64e080d381 Python 3.13.17 2026-10-21 15:48:20 +02:00
Thomas Wouters 855c7403f0 Post 3.13.16 2026-09-30 23:54:55 +02:00
Thomas Wouters cbc944f4bc Python 3.13.16 2026-09-30 20:57:20 +02:00
Victor Stinner a4ab2c1c69 [3.13] gh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (#157067) (#157189)
gh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (#157067)

* Enhance Py_CLEAR() test in test_cext and test_cppext.
  Check that Py_CLEAR(obj) sets obj to NULL.
* Add also tests on Py_SETREF() and Py_BEGIN_CRITICAL_SECTION().

(cherry picked from commit 36c7440c48)
2026-09-08 15:17:38 +00:00
Thomas Wouters 549462e5b1 Post 3.13.15 2026-08-05 16:57:05 +02:00
Thomas Wouters 4061bc4c35 Python 3.13.15 2026-08-05 14:25:43 +02:00
Victor Stinner 5baaa5b86d [3.13] gh-152132: Test Py_CompileString() in test_capi.test_run (#153470) (#153473) (#153533)
[3.14] gh-152132: Test Py_CompileString() in test_capi.test_run (#153470) (#153473)

gh-152132: Test Py_CompileString() in test_capi.test_run (#153470)

PyRun functions now raises ValueError if the start argument is
invalid.

Add Modules/_testlimitedcapi/run.c.

(cherry picked from commit d83d26724b)
(cherry picked from commit 6374772d8c)
2026-07-10 22:25:22 +00:00
Victor Stinner 3d9a42049e [3.13] gh-152132: Fix Py_RunMain() to return an exit code (#153446) (#153455) (#153458)
[3.14] gh-152132: Fix Py_RunMain() to return an exit code (#153446) (#153455)

gh-152132: Fix Py_RunMain() to return an exit code (#153446)

* Fix Py_RunMain() to return an exit code, rather than calling
  Py_Exit(), when running a script, a command, or the REPL.
* _PyRun_SimpleFile() now logs errors to stderr, for example if setting
  __main__.__file__ fails.
* Add tests on Py_RunMain() exitcode.
* Rename functions:

  * _PyRun_SimpleStringFlagsWithName() => _PyRun_SimpleString()
  * _PyRun_SimpleFileObject() => _PyRun_SimpleFile()
  * _PyRun_AnyFileObject() => _PyRun_AnyFile()
  * _PyRun_InteractiveLoopObject() => _PyRun_InteractiveLoop()

* Change _PyRun_SimpleString(), _PyRun_SimpleFile(), _PyRun_AnyFile() and
  _PyRun_InteractiveLoop() return type to PyObject*.
* pymain_repl() now displays the error if PySys_Audit() or
  import _pyrepl failed.
* PyRun_SimpleFileExFlags() and PyRun_AnyFileExFlags() now log
  PyUnicode_DecodeFSDefault() error. So these functions can no longer
  return -1 with an exception set.

(cherry picked from commit fac72f1ee9)
(cherry picked from commit 62c34a62c2)
2026-07-09 22:50:58 +02:00
Donghee Na 4a435e5f2c [3.13] gh-153083: Defer GC tracking of an array to the end of construction. (gh-153284) (gh-153338)
(cherry picked from commit 8615062fd5)
2026-07-08 13:12:43 +00:00
Serhiy StorchakaandClaude Opus 4.8 79d2264bc3 [3.13] gh-152502: Detect the curses mouse interface portably (GH-152705) (GH-152735)
The mouse interface (getmouse(), the BUTTON* constants, ...) was gated on the
ncurses-specific NCURSES_MOUSE_VERSION macro, so it was dropped on other curses
implementations that provide it, such as NetBSD curses and PDCurses.

Gate it instead on a configure capability probe or the PDCURSES macro.  Probe
for getmouse() with its X/Open getmouse(MEVENT *) signature, since PDCurses
declares an incompatible getmouse(void) unless built for the ncurses mouse API,
which PDC_NCMOUSE now always selects.

(cherry picked from commit 7bbea4f486)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 05:30:45 +00:00
Thomas Wouters d3e29c1157 Post 3.13.14 2026-06-10 18:01:10 +02:00
Thomas Wouters fd17997c38 Python 3.13.14 2026-06-10 14:24:04 +02:00
Stan Ulbrych fc9b11ff49 [3.13] gh-149018: Use XML_SetHashSalt16Bytes in pyexpat/_elementtree when possible (GH-149023)
(cherry picked from commit 24b8f12544)
2026-06-09 14:45:59 +00:00
Stan UlbrychandBénédikt Tran 19bc39127e [3.13] gh-90949: expose Expat API to tune exponential expansion protections (GH-139368)
Expose the XML Expat 2.7.2 APIs to tune protections against
"billion laughs" [1] attacks.

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

- `parser.SetBillionLaughsAttackProtectionActivationThreshold(threshold)`, and
- `parser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor)`.

This completes the work in f04bea44c3,
and improves the existing related documentation.

[1]: https://en.wikipedia.org/wiki/Billion_laughs_attack
(cherry picked from commit 666112376d)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-09 15:23:22 +01:00
Miss Islington (bot)andVictor Stinner fd1b5c638a [3.13] gh-150907: Fix dynamic_annotations.h when built with C++ and Valgrind (GH-150914) (#150964)
gh-150907: Fix dynamic_annotations.h when built with C++ and Valgrind (GH-150914)

Add extern "C++" scope for the C++ template.

Fix test_cppext when Python is built with --with-valgrind.
(cherry picked from commit c32501261a)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-06-05 12:29:28 +00:00
Thomas Wouters 12683e3ce8 Post 3.13.13 2026-04-07 23:28:57 +02:00
Thomas Wouters 01104ce1be Python 3.13.13 2026-04-07 20:19:01 +02:00
Victor StinnerandSergey B Kirpichev 01af34a364 [3.13] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (#145901) (#147437)
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().

Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit db5936c5b8)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-03-31 17:06:38 +02:00
Matas Kaminskas 793a86f8a0 [3.13] gh-129259: Fix AIX build failures caused by incorrect struct alignment (GH-144917) 2026-03-24 02:47:53 +01:00
T. Wouters 684e7af8cd [3.13] gh-142183: Cache one datachunk per tstate to prevent alloc/dealloc thrashing (GH-145789) (#146123)
* gh-142183: Cache one datachunk per tstate to prevent alloc/dealloc thrashing (GH-145789) (#145828)

Cache one datachunk per tstate to prevent alloc/dealloc thrashing when repeatedly hitting the same call depth at exactly the wrong boundary.

Move new _ts member to the end to not mess up remote debuggers' ideas of the
struct's layout. (The struct is only created by the runtime, and the new
field only used by the runtime, so it should be safe.)

(cherry picked from commit 706fd4ec08)
(cherry picked from commit 19cbcc0f85)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
2026-03-24 02:27:57 +01:00
Sam Gross fa2f9a3bf8 [3.13] gh-146227: Fix wrong type in _Py_atomic_load_uint16 in pyatomic_std.h (gh-146229) (#146233)
Also fix a related issue in the pyatomic headers:

* Fix pseudo-code comment for _Py_atomic_store_ptr_release in
  pyatomic.h.

(cherry picked from commit 1eff27f2c0)
2026-03-20 20:08:29 +00:00
Ken Jin 85f8e76705 [3.13] gh-145008: Maintain stack consistency in CALL_BOUND_METHOD_EXACT_ARGS (GH-145015) 2026-03-03 04:09:02 +08:00
Thomas Wouters cc1f81bb45 Post 3.13.12 2026-02-03 22:47:48 +01:00
Thomas Wouters 1cbe481834 Python 3.13.12 2026-02-03 18:53:27 +01:00
Petr Viktorin fdac87ae39 [3.13] gh-127773: Disable attribute cache on incompatible MRO entries (GH-127924) (GH-143729) 2026-01-26 16:31:52 +01:00
Pablo Galindo Salgado de34f6d404 [3.13] gh-143228: Fix UAF in perf trampoline during finalization (GH-143233) (#143248) 2025-12-28 14:32:16 +00:00
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
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 StorchakaandSergey B Kirpichev 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 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