| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
(gh-120009)
We make use of the same mechanism that we use for the static builtin types. This required a few tweaks.
This change is the final piece needed to make _datetime support multiple interpreters. I've updated the module slot accordingly.
(cherry picked from commit 105f22ea46ac16866e6df18ebae2a8ba422b7f45, AKA gh-119929)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
|
|
|
|
|
|
|
| |
This makes the support official.
(cherry picked from commit dba7a167dbbd50e83e58df351f3414b7a08e0188, AKA gh-119991)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I was able to make use of the existing datetime_state struct, but there was one tricky thing I had to sort out. We mostly aren't converting to heap types, so we can't use things like PyType_GetModuleByDef() to look up the module state. The solution I came up with is somewhat novel, but I consider it straightforward. Also, it shouldn't have much impact on performance.
In summary, this main changes here are:
* I've added some macros to help hide how various objects relate to module state
* as a solution to the module state lookup problem, I've stored the last loaded module on the current interpreter's internal dict (actually a weakref)
* if the static type method is used after the module has been deleted, it is reloaded
* to avoid extra work when loading the module, we directly copy the objects (new refs only) from the old module state into the new state if the old module hasn't been deleted yet
* during module init we set various objects on the static types' __dict__s; to simplify things, we only do that the first time; once those static types have a separate __dict__ per interpreter, we'll do it every time
* we now clear the module state when the module is destroyed (before, we were leaking everything in _datetime_global_state)
(cherry picked from commit d82a7ba041321e7b58a5a9bbc394670be6ceeb7c, AKA gh-119810)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
|
|
|
|
|
| |
Fix itertools.count in free-threading mode
(cherry picked from commit 87939bd5790accea77c5a81093f16f28d3f0b429)
Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
|
|
|
|
|
|
|
|
|
|
|
| |
The free-threaded build currently immortalizes objects that use deferred
reference counting (see gh-117783). This typically happens once the
first non-main thread is created, but the behavior can be suppressed for
tests, in subinterpreters, or during a compile() call.
This fixes a race condition involving the tracking of whether the
behavior is suppressed.
(cherry picked from commit 47fb4327b5c405da6df066dcaa01b7c1aefab313)
|
|
|
|
|
|
|
|
|
|
| |
(… (#119906)
Revert "[3.13] gh-69214: Fix fcntl.ioctl() request type (GH-119498) (#119504)"
This reverts commit 0bab0b3a53da735838720f96f3d3bf86ca6ba125.
The change modified how negative values, like termios.TIOCSWINSZ, was
treated and is actually backward incompatible.
|
|
|
|
|
| |
(cherry picked from commit 78d697b7d5ec2a6fa046b0e1c34e804f49e750b4)
Co-authored-by: Steve Dower <steve.dower@python.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`PyThreadState_Clear()` (GH-119753) (#119859)
Make sure that `gilstate_counter` is not zero in when calling
`PyThreadState_Clear()`. A destructor called from `PyThreadState_Clear()` may
call back into `PyGILState_Ensure()` and `PyGILState_Release()`. If
`gilstate_counter` is zero, it will try to create a new thread state before
the current active thread state is destroyed, leading to an assertion failure
or crash.
(cherry picked from commit bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c)
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-103846) (GH-119830)
Some of standard Tcl types were renamed, removed, or no longer
registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl
values to Python values to avoid returning a Tcl_Obj where the primary
Python types (int, bool, str, bytes) were returned in older Tcl.
(cherry picked from commit 94e9585e99abc2d060cedc77b3c03e06b4a0a9c4)
Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
|
|
|
|
|
|
|
|
|
|
|
| |
(gh-119637) (gh-119695)
This is the only static type in the module that we will not keep static.
(cherry picked from commit 548a11d5cf1dbb32d86ce0c045130c77f50c1427)
(cherry-picked from commit 34f9b3e7244615d2372614b20e10250e68cc8e61)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Co-authored by: Kirill Podoprigora <kirill.bast9@mail.ru>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-119468)
gh-117142: Slightly hacky fix for memory leak of StgInfo (GH-119424)
Add a funciton that inlines PyObject_GetTypeData and skips
type-checking, so it doesn't need access to the CType_Type object.
This will break if the memory layout changes, but should
be an acceptable solution to enable ctypes in subinterpreters in
Python 3.13.
Mark _ctypes as safe for multiple interpreters
(cherry picked from commit a192547dfe7c4f184cc8b579c3eff2f61f642483)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
|
|
|
|
|
|
|
|
|
| |
This is an unrevert of d58ebf0 (gh-119636), which was reverted by 9216a53 (gh-119639) due to problems which have been resolved.
This is minimal support for multiphase init. Subinterpreters are not supported yet. That will be addressed in a later change.
(cherry picked from commit 3e8b609)
Co-authored-by: Erlend E. Aasland erlend@python.org
|
|
|
|
|
|
|
|
|
|
|
| |
(#119716)
gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712)
When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.
(cherry picked from commit 7ca74a760a5d3cdf48159f003d4db7c2778e9261)
|
|
|
|
|
|
|
| |
This is a backport of 3 commits that go together.
(cherry picked from commit a895756)
(cherry picked from commit b30d30c)
(cherry picked from commit a89fc26)
|
|
|
|
|
|
|
| |
(#119639)
Revert "[3.13] gh-117398: Add multiphase support to _datetime (gh-119373) (gh-119636)"
This reverts commit d58ebf073c755c2f0f6e4ef2296b48a4c75e5f1c.
|
|
|
|
|
|
|
|
| |
This is minimal support. Subinterpreters are not supported yet. That will be addressed in a later change.
(cherry picked from commit 3e8b60905e97a4fe89bb24180063732214368938)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
|
|
|
|
|
|
| |
The fix in gh-119561 introduced an assertion that doesn't hold true if any of the three new test extension modules are loaded more than once. This is fine normally but breaks if the new test_check_state_first() is run more than once, which happens for refleak checking and with the regrtest --forever flag. We fix that here by clearing each of the three modules after loading them. We also tweak a check in _modules_by_index_check().
(cherry picked from commit ae7b17673f29efe17b416cbcfbf43b5b3ff5977c)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
|
|
|
|
|
|
|
|
| |
(gh-119632)
The assertion was added in gh-118532 but was based on the invalid assumption that PyState_FindModule() would only be called with an already-initialized module def. I've added a test to make sure we don't make that assumption again.
(cherry picked from commit 0c5ebe13e9937c446e9947c44f2570737ecca135)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
|
|
|
|
|
|
| |
posixmodule (GH-118355)
(cherry picked from commit 96b392df303b2cfaea823afcb462c0b455704ce8)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
|
|
|
|
|
|
|
|
|
| |
gh-69214: Fix fcntl.ioctl() request type (GH-119498)
Use an 'unsigned long' instead of an 'unsigned int' for the request
parameter of fcntl.ioctl() to support requests larger than UINT_MAX.
(cherry picked from commit 92fab3356f4c61d4c73606e4fae705c6d8f6213b)
Co-authored-by: Victor Stinner <vstinner@python.org>
|
|
|
|
|
|
|
|
|
|
| |
monitoring (GH-119216) (#119497)
* gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (GH-119216)
(cherry picked from commit 6e9863d7a3516cc76d6ce13923b15620499f3855)
---------
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Interpreters (gh-119331) (gh-119410)
_PyArg_Parser holds static global data generated for modules by Argument Clinic. The _PyArg_Parser.kwtuple field is a tuple object, even though it's stored within a static global. In some cases the tuple is statically allocated and thus it's okay that it gets shared by multiple interpreters. However, in other cases the tuple is set lazily, allocated from the heap using the active interprepreter at the point the tuple is needed.
This is a problem once that interpreter is destroyed since _PyArg_Parser.kwtuple becomes at dangling pointer, leading to crashes. It isn't a problem if the tuple is allocated under the main interpreter, since its lifetime is bound to the lifetime of the runtime. The solution here is to temporarily switch to the main interpreter. The alternative would be to always statically allocate the tuple.
This change also fixes a bug where only the most recent parser was added to the global linked list.
(cherry picked from commit 81865002aee8eaaeb3c7e402f86183afa6de77bf)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
|
|
|
|
|
|
| |
(GH-118755)
(cherry picked from commit b64182550f73e556344bd754d32e3be5d22a74e1)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
|
|
|
|
|
|
|
|
|
| |
API (GH-119063) (GH-119106)
The source line was not displayed if the warnings module had not yet
been imported.
(cherry picked from commit 100c7ab00ab66a8c0d54582f35e38d8eb691743c)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
|
|
|
|
|
| |
(cherry picked from commit 94591dca510c796c7d40e9b4167ea56f2fdf28ca)
Co-authored-by: Steve Dower <steve.dower@python.org>
|
|
|
|
|
|
|
|
| |
(GH-118999) (#119018)
gh-118998: Handle errors correctly in `tmtotuple` in `timemodule` (GH-118999)
(cherry picked from commit fc757925944a9486d4244853dbe6e37ab3e560c2)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
| |
(cherry picked from commit 13d7cf997bc9c22cf67c42fd799413e8325e0039)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
|
|
|
|
| |
(cherry picked from commit e85e8deaf3220c8d12b69294e45645aaf20187b9)
Co-authored-by: Dobatymo <Dobatymo@users.noreply.github.com>
|
|
|
|
|
|
|
|
|
|
| |
object (GH-115433)" (GH-118861) (#118872)
This reverts commit ad4f909e0e7890e027c4ae7fea74586667242ad3.
The API ended up not being used.
(cherry picked from commit 46c808172fd3148e3397234b23674bf70734fb55)
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
|
|
|
|
|
|
| |
(GH-118800)
(cherry picked from commit 8af84b503d0b62a3db0d806d39f42c1e08746079)
Co-authored-by: Steve Dower <steve.dower@python.org>
|
|
|
|
|
|
|
|
|
| |
`SemLock.__{enter,exit}__` (GH-118812) (#118856)
These methods are purely wrappers around `Semlock.{acquire,release}`,
which expect a critical section to be held.
(cherry picked from commit c30d8e5d6c6b657817d6b342f1021676d04dd5af)
Co-authored-by: mpage <mpage@meta.com>
|
|
|
|
|
| |
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
|
|
|
|
|
| |
read (#118591)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
|
|
|
|
|
|
|
|
|
| |
Callbacks registered in the tkinter module now take arguments as
various Python objects (int, float, bytes, tuple), not just str.
To restore the previous behavior set tkinter module global wantobject to 1
before creating the Tk object or call the wantobject() method of the Tk object
with argument 1.
Calling it with argument 2 restores the current default behavior.
|
|
|
|
|
|
|
| |
Fix an edge case in `binascii.a2b_base64` strict mode, where
excessive padding was not detected when no padding is necessary.
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
|
|
|
| |
use thread state set of dict versions
|
|
|
|
|
|
| |
We already intern and immortalize most string constants. In the
free-threaded build, other constants can be a source of reference count
contention because they are shared by all threads running the same code
objects.
|
| |
|
|
|
|
|
|
|
| |
of concurrent mutators (#118454)
Add _PyType_LookupRef and use incref before setting attribute on type
Makes setting an attribute on a class and signaling type modified atomic
Avoid adding re-entrancy exposing the type cache in an inconsistent state by decrefing after type is updated
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is an experimental feature, for internal use.
Setting tkinter._debug = True before creating the root window enables
printing every executed Tcl command (or a Tcl command equivalent to the
used Tcl C API).
This will help to convert a Tkinter example into Tcl script to check
whether the issue is caused by Tkinter or exists in the underlying Tcl/Tk
library.
|
|
|
|
| |
(GH-118645)
|
| |
|
|
|
|
|
|
|
| |
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use the new public Raw functions:
* _PyTime_PerfCounterUnchecked() with PyTime_PerfCounterRaw()
* _PyTime_TimeUnchecked() with PyTime_TimeRaw()
* _PyTime_MonotonicUnchecked() with PyTime_MonotonicRaw()
Remove internal functions:
* _PyTime_PerfCounterUnchecked()
* _PyTime_TimeUnchecked()
* _PyTime_MonotonicUnchecked()
|
|
|
|
| |
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This PR adds the ability to enable the GIL if it was disabled at
interpreter startup, and modifies the multi-phase module initialization
path to enable the GIL when loading a module, unless that module's spec
includes a slot indicating it can run safely without the GIL.
PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went
with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148.
A warning will be issued up to once per interpreter for the first
GIL-using module that is loaded. If `-v` is given, a shorter message
will be printed to stderr every time a GIL-using module is loaded
(including the first one that issues a warning).
|
|
|
|
| |
available (GH-118425)
|
|
|
|
|
| |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
|
|
|
| |
This change will make some later changes simpler.
|