Commit Graph

5473 Commits

Author SHA1 Message Date
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
Miss Islington (bot) 4913b6f944
[3.13] gh-131675: Fix `mi_atomic_yield` in mimalloc on 32-bit ARM (gh-131784) (gh-131954)
Use the standard `__ARM_ARCH` macro, which is supported by GCC and Clang.

The branching logic for of `__ARMEL__` has been removed so if the target
architecture supports v7+ instructions, a yield is emitted, otherwise a nop
is emitted. This covers both big and little endian scenarios.
(cherry picked from commit 03f6c8e239)

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Co-authored-by: Vincent Fazio <vfazio@gmail.com>
2025-03-31 14:58:29 -04:00
Russell Keith-Magee 589f422d1b
[3.13] gh-130940: Remove PyConfig.use_system_logger (#131129)
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions Details
Tests / Check if generated files are up to date (push) Blocked by required conditions Details
Tests / Ubuntu SSL tests with OpenSSL (3.0.15, ubuntu-24.04) (push) Blocked by required conditions Details
Tests / Ubuntu SSL tests with OpenSSL (3.1.7, ubuntu-24.04) (push) Blocked by required conditions Details
Tests / Ubuntu SSL tests with OpenSSL (3.2.3, ubuntu-24.04) (push) Blocked by required conditions Details
Tests / Ubuntu SSL tests with OpenSSL (3.3.2, ubuntu-24.04) (push) Blocked by required conditions Details
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions Details
Tests / Address sanitizer (ubuntu-24.04) (push) Blocked by required conditions Details
Tests / All required checks pass (push) Blocked by required conditions Details
Lint / lint (push) Failing after 34s Details
Tests / Change detection (push) Successful in 27m51s Details
Tests / Docs (push) Has been skipped Details
Tests / Check if the ABI has changed (push) Failing after 31s Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (Win32, false, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (arm64, false, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (arm64, true, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (x64, false, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (x64, true, windows-latest) (push) Has been skipped Details
Tests / Windows MSI${{ '' }} (arm64) (push) Has been skipped Details
Tests / Windows MSI${{ '' }} (x64) (push) Has been skipped Details
Tests / Windows MSI${{ '' }} (x86) (push) Has been skipped Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false, ${{ github.repository_owner != 'python' }}, ghcr.io/cirruslabs/macos-runner:sonoma) (push) Failing after 26m22s Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true, ${{ github.repository_owner != 'python' }}, ghcr.io/cirruslabs/macos-runner:sonoma) (push) Failing after 31s Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false) (push) Failing after 28m19s Details
Tests / WASI (push) Failing after 28m29s Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false, ${{ github.repository_owner != 'python' }}, macos-14) (push) Failing after 33m34s Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false, ${{ github.repository_owner != 'python' }}, macos-13) (push) Failing after 33m34s Details
Tests / CIFuzz (address) (push) Has been skipped Details
Tests / CIFuzz (memory) (push) Has been skipped Details
Tests / CIFuzz (undefined) (push) Has been skipped Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true, ${{ github.repository_owner != 'python' }}, macos-14) (push) Failing after 32m44s Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true) (push) Failing after 36m1s Details
Tests / Thread sanitizer ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false) (push) Failing after 25m11s Details
Tests / Thread sanitizer ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true) (push) Successful in 53m17s Details
Removes ``PyConfig.use_system_logger``, resolving an ABI incompatibility introduced in
3.13.2.

Changes the default behavior of iOS to *always* direct stdout/stderr to the system log.
2025-03-13 11:53:11 +08:00
Miss Islington (bot) f9d19a3ada
[3.13] gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (GH-131044) (#131084)
(cherry picked from commit de8818ae23)

Co-authored-by: Max Bachmann <kontakt@maxbachmann.de>
2025-03-11 11:56:54 +00:00
Miss Islington (bot) 125ca02866
[3.13] gh-129296: Fix `pyatomic.h` include paths (GH-129320) (#130667)
gh-129296: Fix `pyatomic.h` include paths (GH-129320)

Use relative includes in Include/cpython/pyatomic.h for
pyatomic_gcc.h, pyatomic_std.h and pyatomic_msc.h.

Do a similar change in Include/cpython/pythread.h for
pthread_stubs.h include.
(cherry picked from commit 3a974e39d5)

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-02-28 08:22:15 +00:00
Serhiy Storchaka 7c1b76fce8
[3.13] gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) (GH-130556)
The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
(cherry picked from commit 0ef4ffeefd)
2025-02-25 22:50:26 +00:00
Miss Islington (bot) 5d83b6c160
[3.13] gh-130230: Fix crash in pow() with only Decimal third argument (GH-130237) (GH-130246)
(cherry picked from commit b93b7e566e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-02-18 13:18:37 +02:00
Sam Gross 2fbc9861c3
[3.13] gh-128759: Fix accesses to `tp_version_tag`. (GH-129750) (GH-130042)
We should use a relaxed atomic load in the free threading build in
`PyType_Modified()` because that's called without the type lock held.
It's not necessary to use atomics in `type_modified_unlocked()`.

We should also use `FT_ATOMIC_STORE_UINT_RELAXED()` instead of the
`UINT32` variant because `tp_version_tag` is declared as `unsigned int`.
(cherry picked from commit 57f45ee2d8)
2025-02-12 10:43:25 -05:00
Sam Gross 356a9e646c
[3.13] gh-129668: Fix thread-safety of MemoryError freelist in free threaded build (gh-129704) (gh-129742)
The MemoryError freelist was not thread-safe in the free threaded build.
Use a mutex to protect accesses to the freelist. Unlike other freelists,
the MemoryError freelist is not performance sensitive.

(cherry picked from commit 51b4edb1a4)
2025-02-06 13:27:30 -05:00
Thomas Wouters 45d136d7e3 Post 3.13.2 2025-02-04 20:37:26 +01:00
Thomas Wouters 4f8bb3947c Python 3.13.2 2025-02-04 15:51:09 +01:00
Victor Stinner 6b47499510
[3.13] gh-128679: Fix tracemalloc.stop() race conditions (#128897)
tracemalloc_alloc(), tracemalloc_realloc(), PyTraceMalloc_Track(),
PyTraceMalloc_Untrack() and _PyTraceMalloc_TraceRef() now check
tracemalloc_config.tracing after calling TABLES_LOCK().

_PyTraceMalloc_Stop() now protects more code with TABLES_LOCK(),
especially setting tracemalloc_config.tracing to 1.

Add a test using PyTraceMalloc_Track() to test tracemalloc.stop()
race condition.

Call _PyTraceMalloc_Init() at Python startup.
2025-01-18 23:39:07 +00:00
Ed Nutting fdac3629e9
[3.13] gh-127599: Fix _Py_RefcntAdd missing calls to _Py_INCREF_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC (GH-127717) (#128713)
Previously, `_Py_RefcntAdd` hasn't called
`_Py_INCREF_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC` which is incorrect.

Now it has been fixed.
(cherry picked from commit ab05beb8ce)
2025-01-18 19:00:46 +02:00
Miss Islington (bot) fe08cdf265
[3.13] gh-126742: Add _PyErr_SetLocaleString, use it for gdbm & dlerror messages (GH-126746) (GH-128023)
- Add a helper to set an error from locale-encoded `char*`
- Use the helper for gdbm & dlerror messages
(cherry picked from commit 7303f06846)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-17 11:45:29 +00:00
Victor Stinner 8e143b2886
[3.13] gh-127906: Fix Py_BUILD_ASSERT_EXPR() on Windows (#127994)
gh-127906: Fix Py_BUILD_ASSERT_EXPR() on Windows

Change Py_BUILD_ASSERT_EXPR implementation on Windows to avoid a
compiler warning about an unnamed structure.
2024-12-16 17:17:01 +00:00
Peter Bierma bcdd10d0c8
[3.13] gh-127791: Fix, document, and test `PyUnstable_AtExit` (GH-127793) (#127819)
* Fix merge conflicts.

* [3.13] gh-127791: Fix, document, and test `PyUnstable_AtExit` (GH-127793)
(cherry picked from commit d5d84c3f13)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-12-11 13:40:45 +00:00
Pablo Galindo Salgado eb692d945e
[3.13] gh-126076: Account for relocated objects in tracemalloc (GH-126077) (#127823)
(cherry picked from commit 30aeb00d36)
2024-12-11 14:15:37 +01:00
Miss Islington (bot) 78dfc28ff3
[3.13] Add `extern "C"` around `PyTraceMalloc_` functions. (GH-127772) (#127815)
Add `extern "C"` around `PyTraceMalloc_` functions. (GH-127772)

Pretty much everything else exported by Python.h has an extern "C"
annotation, yet this header appears to be missing one.
(cherry picked from commit 2cdeb61b57)

Co-authored-by: Peter Hawkins <hawkinsp@cs.stanford.edu>
2024-12-11 14:07:44 +01:00
Russell Keith-Magee 075c41d5f5
[3.13] gh-126925: Modify how iOS test results are gathered (GH-127592) (#127754)
Adds a `use_system_log` config item to enable stdout/stderr redirection for
Apple platforms. This log streaming is then used by a new iOS test runner
script, allowing the display of test suite output at runtime. The iOS test
runner script can be used by any Python project, not just the CPython test
suite.
(cherry picked from commit 2041a95e68)
2024-12-09 14:39:11 +08:00
Sam Gross 69bb1c6c41
[3.13] gh-127582: Make object resurrection thread-safe for free threading. (GH-127612) (GH-127659)
Objects may be temporarily "resurrected" in destructors when calling
finalizers or watcher callbacks. We previously undid the resurrection
by decrementing the reference count using `Py_SET_REFCNT`. This was not
thread-safe because other threads might be accessing the object
(modifying its reference count) if it was exposed by the finalizer,
watcher callback, or temporarily accessed by a racy dictionary or list
access.

This adds internal-only thread-safe functions for temporary object
resurrection during destructors.
(cherry picked from commit f4f530804b)
2024-12-05 18:49:33 -05:00
Thomas Wouters fd81351186 Post 3.13.1 2024-12-03 22:43:25 +01:00
Thomas Wouters 0671451779 Python 3.13.1 2024-12-03 18:59:52 +01:00
Miss Islington (bot) dddea7c232
[3.13] gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952) (#122984)
gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952)

As of 529a160 (gh-118204), building with HAVE_DYNAMIC_LOADING stopped working.  This is a minimal fix just to get builds working again.  There are actually a number of long-standing deficiencies with HAVE_DYNAMIC_LOADING builds that need to be resolved separately.
(cherry picked from commit ee1b8ce26e)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-12-03 16:46:30 +00:00
Eric Snow 219b8266db
[3.13] gh-126914: Store the Preallocated Thread State's Pointer in a PyInterpreterState Field (gh-127114)
This approach eliminates the originally reported race.  It also gets rid of the deadlock reported in gh-96071, so we can remove the workaround added then.

This is mostly a cherry-pick of 1c0a104 (AKA gh-126989).  The difference is we add PyInterpreterState.threads_preallocated at the end of PyInterpreterState, instead of adding PyInterpreterState.threads.preallocated.  That avoids ABI disruption.
2024-12-02 18:41:57 +00:00
Miss Islington (bot) d9ac6b3ef7
[3.13] gh-125703: Correctly honour tracemalloc hooks on specialized DECREF paths (GH-125704) (#125705)
gh-125703: Correctly honour tracemalloc hooks on specialized DECREF paths (GH-125704)
(cherry picked from commit f8ba9fb2ce)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2024-12-02 15:02:20 +01:00
Miss Islington (bot) 13fe8f946e
[3.13] gh-126688: Reinit import lock after fork (GH-126692) (GH-126765)
The PyMutex implementation supports unlocking after fork because we
clear the list of waiters in parking_lot.c. This doesn't work as well
for _PyRecursiveMutex because on some systems, such as SerenityOS, the
thread id is not preserved across fork().
(cherry picked from commit 5610860840)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-11-12 22:00:42 +00:00
Miss Islington (bot) ce1a1a6021
[3.13] gh-126303: Fix pickling and copying of os.sched_param objects (GH-126336) (GH-126423)
(cherry picked from commit d3840503b0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-05 06:50:33 +00:00
Shantanu 3d8b6f0977
[3.13] gh-123930: Better error for "from imports" when script shadows module (GH-123929) (#125937)
gh-123930: Better error for "from imports" when script shadows module (#123929)

(cherry picked from commit 500f5338a8)
2024-10-24 19:37:31 +00:00
Sam Gross 4b55d53316
[3.13] gh-125268: Use static string for "1e309" in AST (GH-125272) (GH-125280)
When formatting the AST as a string, infinite values are replaced by
1e309, which evaluates to infinity. The initialization of this string
replacement was not thread-safe in the free threading build.
(cherry picked from commit 427dcf24de)
2024-10-24 13:59:23 -04:00
Miss Islington (bot) 5c2696bc26
[3.13] gh-125859: Fix crash when `gc.get_objects` is called during GC (GH-125882) (GH-125921)
This fixes a crash when `gc.get_objects()` or `gc.get_referrers()` is
called during a GC in the free threading build.

Switch to `_PyObjectStack` to avoid corrupting the `struct worklist`
linked list maintained by the GC. Also, don't return objects that are frozen
(`gc.freeze()`) or in the process of being collected to more closely match
the behavior of the default build.
(cherry picked from commit e545ead66c)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-10-24 14:08:15 +00:00
Miss Islington (bot) 18b9079ddb
[3.13] gh-125444: Fix illegal instruction for older Arm architectures (GH-125574) (GH-125595)
On Arm v5 it is not possible to get the thread ID via c13 register
hence the illegal instruction. The c13 register started to provide
thread ID since Arm v6K architecture variant. Other variants of
Arm v6 (T2, Z and base) don’t provide the thread ID via c13.
For the sake of simplicity we group v5 and v6 together and
consider that instructions for Arm v7 only.
(cherry picked from commit feda9aa73a)

Co-authored-by: Diego Russo <diego.russo@arm.com>
2024-10-16 14:48:40 +00:00
Thomas Wouters 8bc8d21ac7 Post 3.13.0 2024-10-07 17:22:36 +02:00
Thomas Wouters 60403a5409 Python 3.13.0 2024-10-07 07:02:14 +02:00
Thomas Wouters e6fb7fa76b Post 3.13.0rc3 2024-10-01 16:15:44 +02:00
Thomas Wouters fae84c70fb Python 3.13.0rc3 2024-10-01 04:03:08 +02:00
T. Wouters e0eb44ad49
[3.13] GH-124567: Revert the Incremental GC in 3.13 (#124770)
Revert the incremental GC in 3.13, since it's not clear that without further turning, the benefits outweigh the costs.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-09-30 21:27:29 +00:00
Miss Islington (bot) 4618c0e5e6
[3.13] gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (GH-124663) (#124698)
gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (GH-124663)
(cherry picked from commit 0881e2d3b1)

Co-authored-by: Tony Roberts <tony@pyxll.com>
2024-09-27 19:58:36 +00:00
Thomas Wouters 660baa14d6 Post 3.13.0rc2 2024-09-07 02:21:10 +02:00
Thomas Wouters ec61006963 Python 3.13.0rc2 2024-09-06 23:15:21 +02:00
Victor Stinner d053204b73
[3.13] gh-123747: Avoid static_assert() in internal header files (#123779) (#123785)
gh-123747: Avoid static_assert() in internal header files (#123779)

(cherry picked from commit ef4b69d2be)
2024-09-06 14:41:09 +00:00
Victor Stinner 10735bff9e
[3.13] gh-123091: Use _Py_IsImmortalLoose() (#123511) (#123600)
gh-123091: Use _Py_IsImmortalLoose() (#123511)

Use _Py_IsImmortalLoose() in bytesobject.c, typeobject.c
and ceval.c.

(cherry picked from commit f1a0d96f41)
2024-09-02 15:23:29 +02:00
Miss Islington (bot) 8ef277e5e9
[3.13] gh-123484: Fix the debug offsets for PyLongObject (GH-123485) (#123499) 2024-08-30 12:05:50 +00:00
Miss Islington (bot) 01ce10c690
[3.13] Add debug offsets for free threaded builds (GH-123041) (#123055)
* Add debug offsets for free threaded builds (GH-123041)
(cherry picked from commit d7a3df9150)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>

* Refresh ABI file

---------

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2024-08-18 15:01:16 +00:00