Commit Graph

5429 Commits

Author SHA1 Message Date
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
Miss Islington (bot) 7ee7558833
[3.13] gh-122584: Import mimalloc headers in a C++ context (GH-122587) (#123035)
gh-122584: Import mimalloc headers in a C++ context (GH-122587)
(cherry picked from commit 1dad23edbc)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2024-08-16 01:49:17 -07:00
Miss Islington (bot) 9fb6bfbef0
[3.13] gh-122581: Avoid data races when collecting parser statistics (GH-122694) (#122733)
gh-122581: Avoid data races when collecting parser statistics (GH-122694)
(cherry picked from commit ce0d66c8d2)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2024-08-07 18:29:03 +05:30
Miss Islington (bot) c1efeb3234
[3.13] gh-120974: Make asyncio `swap_current_task` safe in free-threaded build (GH-122317) (#122612)
gh-120974: Make asyncio `swap_current_task` safe in free-threaded build (GH-122317)

* gh-120974: Make asyncio `swap_current_task` safe in free-threaded build
(cherry picked from commit b5e6fb39a2)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-08-02 13:58:24 +00:00
Thomas Wouters 4588980221 Post 3.13.0rc1 2024-08-01 11:02:31 +02:00
Thomas Wouters e4a3e786a5 Python 3.13.0rc1 2024-07-31 20:18:39 +02:00
Brandt Bucher 55554fd215
[3.13] GH-116090: Fire RAISE events from _FOR_ITER_TIER_TWO (GH-122419)
(cherry picked from commit 15d4cd0967)
2024-07-29 14:51:19 -07:00
Miss Islington (bot) dd270f610c
[3.13] gh-121489: Export private _PyBytes_Join() again (GH-122267) (#122287)
gh-121489: Export private _PyBytes_Join() again (GH-122267)
(cherry picked from commit aef95eb107)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2024-07-25 16:06:31 +00:00
Eric Snow 716c6771fc
[3.13] gh-117482: Simplify the Fix For Builtin Types Slot Wrappers (gh-121932)
In gh-121602, I applied a fix to a builtin types initialization bug.
That fix made sense in the context of some broader future changes,
but introduced a little bit of extra complexity.  For earlier versions
those future changes are not relevant; we can avoid the extra complexity.
Thus we can revert that earlier change and replace it with this one,
which is more focused and conceptually simpler.  This is essentially
the implementation of an idea that @markshannon pointed out to me.

Note that this change would be much smaller if we didn't have to deal
with repr compatibility for builtin types that explicitly inherit tp slots
(see expect_manually_inherited()).  The alternative is to stop
*explicitly* inheriting tp slots in static PyTypeObject values,
which is churn that we can do separately.
2024-07-24 12:02:36 -06:00
Miss Islington (bot) 77ab53a5f3
[3.13] gh-120974: Make _asyncio._leave_task atomic in the free-threaded build (GH-122139) (#122186)
gh-120974: Make _asyncio._leave_task atomic in the free-threaded build (GH-122139)

* gh-120974: Make _asyncio._leave_task atomic in the free-threaded build

Update `_PyDict_DelItemIf` to allow for an argument to be passed to the
predicate.
(cherry picked from commit a15feded71)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-07-23 17:30:58 +00:00
Jakub Kulík 82db81528c
[3.13] gh-118124: fix assert related C++ checks on Solaris/Illumos (GH-121974) (#122108)
Fix check for static_assert() for C++ on some platforms..
(cherry picked from commit e88bd96d0d)
2024-07-22 07:50:20 +00:00
Miss Islington (bot) bf7f4f357b
[3.13] gh-120973: Fix thread-safety issues with `threading.local` (GH-121655) (#122042)
This is a small refactoring to the current design that allows us to
avoid manually iterating over threads.

This should also fix gh-118490.
(cherry picked from commit e059aa6b01)

Co-authored-by: mpage <mpage@meta.com>
2024-07-19 17:49:34 +00:00
Serhiy Storchaka a45d9051ed
[3.13] gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) (GH-122012)
(cherry picked from commit 1a0c7b9ba4)
2024-07-19 09:13:08 +00:00
Miss Islington (bot) 233ed46e6d
[3.13] gh-118934: Make PyEval_GetLocals return borrowed reference (GH-119769) (#121869)
gh-118934: Make PyEval_GetLocals return borrowed reference (GH-119769)
(cherry picked from commit e65cb4c6f0)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2024-07-19 01:38:28 +10:00
Thomas Wouters 98e7d44712 Post 3.13.0b4 2024-07-18 15:53:44 +02:00
Thomas Wouters 567c38b4eb Python 3.13.0b4 2024-07-18 11:41:38 +02:00
Miss Islington (bot) afa5321c6c
[3.13] gh-121621: Move asyncio_running_loop to private struct (GH-121939) (#121943)
gh-121621: Move asyncio_running_loop to private struct (GH-121939)

This avoids changing the ABI and keeps the field in the private struct.
(cherry picked from commit 81fd625b5c)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-07-18 01:52:39 -07:00
Miss Islington (bot) f7b2b2a8fb
[3.13] gh-121528: Fix _PyObject_Init() assertion for stable ABI (GH-121725) (#121936)
gh-121528: Fix _PyObject_Init() assertion for stable ABI (GH-121725)

Add _Py_IsImmortalLoose() function for assertions.
(cherry picked from commit b826e459ca)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-07-17 20:14:22 +00:00
Miss Islington (bot) f888636182
[3.13] GH-121583: Remove dependency from pystats.h to internal header file (GH-121880)
(cherry picked from commit f036a463db)
Co-authored-by: Michael Droettboom <mdboom@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-07-16 23:03:07 +00:00
Miss Islington (bot) 06d76c4b94
[3.13] gh-121621: Move asyncio running loop to thread state (GH-121695) (GH-121864)
gh-121621: Move asyncio running loop to thread state (GH-121695)
(cherry picked from commit 69c68de43a)

Co-authored-by: Ken Jin <kenjin@python.org>
2024-07-17 01:57:37 +08:00
Miss Islington (bot) 0a634e3702
[3.13] gh-121546: Disable contextvar caching on free-threading build (GH-121740) (#121808)
gh-121546: Disable contextvar caching on free-threading build (GH-121740)
(cherry picked from commit e904300882)

Co-authored-by: Ken Jin <kenjin@python.org>
2024-07-15 16:53:52 -04:00
Miss Islington (bot) 8f3ffb4156
[3.13] gh-121700 Emscripten trampolines not quite right since GH-106219 (GH-121701) (GH-121744)
(cherry picked from commit 3086b86cfd)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2024-07-14 12:37:00 +02:00
Miss Islington (bot) 48a96d23a8
[3.13] gh-120642: Move _PyCode_CODE() to the internal C API (GH-121644) (#121729)
gh-120642: Move _PyCode_CODE() to the internal C API (GH-121644)

Move _PyCode_CODE() and _PyCode_NBYTES() macros to the internal C API
since they use _Py_CODEUNIT which is only part of the internal C API.
(cherry picked from commit a2bec77d25)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-07-13 21:31:30 +00:00
Ken Jin cd74ed0a71
[3.13] gh-120198: Stop the world when setting __class__ on free-threaded build (#121591)
(cherry-picked from commit 3bfc9c8)
2024-07-12 19:35:53 +08:00
Miss Islington (bot) c6dbfbbe3c
[3.13] gh-117482: Fix Builtin Types Slot Wrappers (gh-121630)
When builtin static types are initialized for a subinterpreter, various "tp" slots have already been inherited (for the main interpreter).  This was interfering with the logic in add_operators() (in Objects/typeobject.c), causing a wrapper to get created when it shouldn't.  This change fixes that by preserving the original data from the static type struct and checking that.

(cherry picked from commit 5250a03133, AKA gh-121602)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-07-11 20:47:38 +00:00
Miss Islington (bot) 0504f45b79
[3.13] gh-89364: Export PySignal_SetWakeupFd() function (GH-121537) (#121582)
gh-89364: Export PySignal_SetWakeupFd() function (GH-121537)

Export the PySignal_SetWakeupFd() function. Previously, the function
was documented but it couldn't be used in 3rd party code.
(cherry picked from commit ca0fb3423c)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-07-10 14:14:09 +00:00
Miss Islington (bot) c128718f30
[3.13] gh-121368: Fix seq lock memory ordering in _PyType_Lookup (GH-121388) (#121505)
The `_PySeqLock_EndRead` function needs an acquire fence to ensure that
the load of the sequence happens after any loads within the read side
critical section. The missing fence can trigger bugs on macOS arm64.

Additionally, we need a release fence in `_PySeqLock_LockWrite` to
ensure that the sequence update is visible before any modifications to
the cache entry.
(cherry picked from commit 1d3cf79a50)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-07-08 19:15:58 +00:00
Miss Islington (bot) eef5c6443b
[3.13] gh-121487: Fix deprecation warning for ATOMIC_VAR_INIT in mimalloc (gh-121488) (#121504)
(cherry picked from commit 31873bea47)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2024-07-08 18:59:25 +00:00
Miss Islington (bot) 273c993b06
[3.13] gh-106597: Remove unnecessary CFrame offsets (GH-121369) (#121370)
gh-106597: Remove unnecessary CFrame offsets (GH-121369)
(cherry picked from commit f5c8d67de6)

Co-authored-by: Gabriele N. Tornetta <P403n1x87@users.noreply.github.com>
2024-07-04 17:52:03 +00:00
Miss Islington (bot) 3d4e533be5
[3.13] gh-112136: Restore removed _PyArg_Parser (GH-121262) (#121344)
gh-112136: Restore removed _PyArg_Parser (GH-121262)

Restore the private _PyArg_Parser structure and the private
_PyArg_ParseTupleAndKeywordsFast() function, previously removed
in Python 3.13 alpha 1.

Recreate Include/cpython/modsupport.h header file.
(cherry picked from commit f8373db153)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-07-03 18:29:00 +00:00
Miss Islington (bot) d3e586e652
[3.13] gh-106597: Add more offsets to _Py_DebugOffsets (GH-121311) (#121312)
gh-106597: Add more offsets to _Py_DebugOffsets (GH-121311)

Add more offsets to _Py_DebugOffsets

We add a few more offsets that are required by some out-of-process
tools, such as [Austin](https://github.com/p403n1x87/austin).
(cherry picked from commit c9bdfbe868)

Co-authored-by: Gabriele N. Tornetta <P403n1x87@users.noreply.github.com>
2024-07-03 09:18:15 +00:00
Miss Islington (bot) 89bf33732f
[3.13] gh-115773: Add sizes to debug offset structure (GH-120112) (#121283)
gh-115773: Add sizes to debug offset structure (GH-120112)
(cherry picked from commit b180788d4a)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2024-07-02 18:19:26 +00:00
Miss Islington (bot) 06fd745dd9
[3.13] gh-117657: Fix data races reported by TSAN in some set methods (GH-120914) (#121240)
Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed
atomic loads in the free-threaded build.

After this change, the TSAN doesn't report data races for this method.
(cherry picked from commit 294e724964)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2024-07-01 19:40:28 +00:00
Miss Islington (bot) 82777cd024
[3.13] gh-113565: Improve and harden detection of curses dependencies (GH-119816) (#121202)
1. Use pkg-config to check for ncursesw/panelw. If that fails, use
   pkg-config to check for ncurses/panel.
2. Regardless of pkg-config output, search for curses/panel headers, so
   we're sure we have all defines in pyconfig.h.
3. Regardless of pkg-config output, check if libncurses or libncursesw
   contains the 'initscr' symbol; if it does _and_ pkg-config failed
   earlier, add the resulting -llib linker option to CURSES_LIBS.
   Ditto for 'update_panels' and PANEL_LIBS.
4. Wrap the rest of the checks with WITH_SAVE_ENV and make sure we're
   using updated LIBS and CPPFLAGS for those.

Add the PY_CHECK_CURSES convenience macro.
(cherry picked from commit f80376b129)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2024-07-01 08:35:38 +00:00
Miss Islington (bot) 7776179ec4
[3.13] gh-119447: Fix build with _PY_SHORT_FLOAT_REPR == 0 (GH-121178) (#121179)
gh-119447: Fix build with _PY_SHORT_FLOAT_REPR == 0 (GH-121178)
(cherry picked from commit c3677befbe)

Co-authored-by: Yureka <yuka@yuka.dev>
2024-06-30 10:04:39 +00:00
Miss Islington (bot) 58a3c3c0ad
gh-121115: Skip __index__ in PyLong_AsNativeBytes by default (GH-121118)
(cherry picked from commit 2894aa14f2)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-06-28 15:52:26 +00:00
Thomas Wouters 71d41f4e7d Post 3.13.0b3 2024-06-27 20:34:22 +02:00
Thomas Wouters 7b413952e8 Python 3.13.0b3 2024-06-27 15:06:51 +02:00
Miss Islington (bot) c052b192aa
[3.13] gh-120838: Add _PyThreadState_WHENCE_FINI (gh-121013)
We also add _PyThreadState_NewBound() and drop _PyThreadState_SetWhence().

This change only affects internal API.

(cherry picked from commit a905721b9c, AKA gh-121010)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-06-26 15:32:00 -06:00
Miss Islington (bot) 64c4139f61
[3.13] gh-120593: Fix const qualifier in pyatomic.h (GH-121055) (#121057)
gh-120593: Fix const qualifier in pyatomic.h (GH-121055)
(cherry picked from commit 9cd2dcbb87)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-06-26 18:37:28 +00:00
Victor Stinner e26e0985d9
[3.13] gh-120642: Move private PyCode APIs to the internal C API (#120643) (#121043)
gh-120642: Move private PyCode APIs to the internal C API (#120643)

* Move _Py_CODEUNIT and related functions to pycore_code.h.
* Move _Py_BackoffCounter to pycore_backoff.h.
* Move Include/cpython/optimizer.h content to pycore_optimizer.h.
* Remove Include/cpython/optimizer.h.
* Remove PyUnstable_Replace_Executor().

Rename functions:

* PyUnstable_GetExecutor() => _Py_GetExecutor()
* PyUnstable_GetOptimizer() => _Py_GetOptimizer()
* PyUnstable_SetOptimizer() => _Py_SetTier2Optimizer()
* PyUnstable_Optimizer_NewCounter() => _PyOptimizer_NewCounter()
* PyUnstable_Optimizer_NewUOpOptimizer() => _PyOptimizer_NewUOpOptimizer()

(cherry picked from commit 9e4a81f00f)
2024-06-26 15:35:19 +02:00
Petr Viktorin 9769b7ae06
[3.13] gh-113993: Allow interned strings to be mortal, and fix related issues (GH-120520) (GH-120945)
* Add an InternalDocs file describing how interning should work and how to use it.

* Add internal functions to *explicitly* request what kind of interning is done:
  - `_PyUnicode_InternMortal`
  - `_PyUnicode_InternImmortal`
  - `_PyUnicode_InternStatic`

* Switch uses of `PyUnicode_InternInPlace` to those.

* Disallow using `_Py_SetImmortal` on strings directly.
  You should use `_PyUnicode_InternImmortal` instead:
  - Strings should be interned before immortalization, otherwise you're possibly
    interning a immortalizing copy.
  - `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to
    `SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in
    backports, as they are now part of public API and version-specific ABI.

* Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery.

* Make sure the statically allocated string singletons are unique. This means these sets are now disjoint:
  - `_Py_ID`
  - `_Py_STR` (including the empty string)
  - one-character latin-1 singletons

  Now, when you intern a singleton, that exact singleton will be interned.

* Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic).

* Intern `_Py_STR` singletons at startup.

* For free-threaded builds, intern `_Py_LATIN1_CHR` singletons at startup.

* Beef up the tests. Cover internal details (marked with `@cpython_only`).

* Add lots of assertions

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-06-24 20:24:19 +02:00
Miss Islington (bot) 447e07ab3d
[3.13] gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove from public API/ABI (GH-119680, GH-120955) (GH-120944)
- gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove from public API/ABI (GH-119680)
  (cherry picked from commit ce1064e4c9)

- gh-119521: Use `PyAPI_DATA`, not `extern`, for `_PyExc_IncompleteInputError` (GH-120955)
  (cherry picked from commit ac61d58db0)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-06-24 20:23:30 +02:00
Sam Gross 4dc27bc0b7
[3.13] gh-119344: Make critical section API public (GH-119353) (#120856)
This makes the following macros public as part of the non-limited C-API for
locking a single object or two objects at once.

* `Py_BEGIN_CRITICAL_SECTION(op)` / `Py_END_CRITICAL_SECTION()`
* `Py_BEGIN_CRITICAL_SECTION2(a, b)` / `Py_END_CRITICAL_SECTION2()`

The supporting functions and structs used by the macros are also exposed for
cases where C macros are not available.
(cherry picked from commit 8f17d69b7b)
2024-06-21 20:20:41 +00:00
Sam Gross 3cb6c4cd60
[3.13] gh-117511: Make PyMutex public in the non-limited API (GH-117731) (#120800)
(cherry picked from commit 3af7263037)
2024-06-20 16:00:25 +00:00