summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-117398: Use Per-Interpreter State for the _datetime Static Types ↵Miss Islington (bot)2024-06-031-55/+142
| | | | | | | | | | | (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>
* [3.13] gh-117142: Support Importing ctypes in Isolated Interpreters (gh-120008)Miss Islington (bot)2024-06-031-1/+1
| | | | | | | | 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>
* [3.13] gh-117398: Add datetime Module State (gh-120004)Miss Islington (bot)2024-06-031-162/+370
| | | | | | | | | | | | | | | | 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>
* [3.13] gh-117657: Fix itertools.count thread safety (GH-119268) (#120007)Sam Gross2024-06-031-9/+31
| | | | | | Fix itertools.count in free-threading mode (cherry picked from commit 87939bd5790accea77c5a81093f16f28d3f0b429) Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
* [3.13] gh-117657: Fix race involving immortalizing objects (GH-119927) (#120005)Sam Gross2024-06-031-15/+9
| | | | | | | | | | | 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)
* [3.13] Revert "[3.13] gh-69214: Fix fcntl.ioctl() request type (GH-119498) ↵Victor Stinner2024-06-012-9/+8
| | | | | | | | | | (… (#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.
* gh-119690: Adds Unicode support for named pipes in _winapi (GH-119717)Miss Islington (bot)2024-05-312-28/+33
| | | | | (cherry picked from commit 78d697b7d5ec2a6fa046b0e1c34e804f49e750b4) Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.13] gh-119585: Fix crash involving `PyGILState_Release()` and ↵Miss Islington (bot)2024-05-311-0/+9
| | | | | | | | | | | | | `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>
* [3.13] gh-103194: Fix Tkinter’s Tcl value type handling for Tcl 8.7/9.0 ↵Miss Islington (bot)2024-05-311-18/+32
| | | | | | | | | | | (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>
* [3.13] gh-117398: Convert datetime.IsoCalendarDate To A Heap Type ↵Miss Islington (bot)2024-05-301-22/+63
| | | | | | | | | | | (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>
* [3.13] gh-117142: Slightly hacky fix for memory leak of StgInfo (GH-119424) ↵Miss Islington (bot)2024-05-302-53/+45
| | | | | | | | | | | | | | | | | | (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>
* [3.13] gh-117398: Add multiphase support to _datetime (gh-119694)Eric Snow2024-05-291-15/+11
| | | | | | | | | 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
* [3.13] gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712) ↵Victor Stinner2024-05-2911-16/+34
| | | | | | | | | | | (#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)
* [3.13] gh-117398: Statically Allocate the Datetime C-API (GH-119472) (gh-119641)Eric Snow2024-05-281-110/+188
| | | | | | | 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)
* [3.13] gh-117398: Revert gh-119636, Add multiphase support to _datetime ↵Eric Snow2024-05-281-11/+15
| | | | | | | (#119639) Revert "[3.13] gh-117398: Add multiphase support to _datetime (gh-119373) (gh-119636)" This reverts commit d58ebf073c755c2f0f6e4ef2296b48a4c75e5f1c.
* [3.13] gh-117398: Add multiphase support to _datetime (gh-119373) (gh-119636)Miss Islington (bot)2024-05-271-15/+11
| | | | | | | | 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>
* [3.13] gh-119584: Fix test_import Failed Assertion (gh-119623) (gh-119633)Miss Islington (bot)2024-05-271-0/+3
| | | | | | | 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>
* [3.13] gh-119560: Drop an Invalid Assert in PyState_FindModule() (gh-119561) ↵Miss Islington (bot)2024-05-271-2/+89
| | | | | | | | | (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>
* gh-118263: Add additional arguments to path_t (Argument Clinic type) in ↵Miss Islington (bot)2024-05-242-285/+362
| | | | | | | posixmodule (GH-118355) (cherry picked from commit 96b392df303b2cfaea823afcb462c0b455704ce8) Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
* [3.13] gh-69214: Fix fcntl.ioctl() request type (GH-119498) (#119504)Miss Islington (bot)2024-05-242-8/+9
| | | | | | | | | 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>
* [3.13] gh-118692: Avoid creating unnecessary StopIteration instances for ↵Miss Islington (bot)2024-05-241-4/+5
| | | | | | | | | | 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>
* [3.13] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across ↵Miss Islington (bot)2024-05-222-1/+81
| | | | | | | | | | | | | 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-118507 : Refactor `nt._path_is*` to improve applicability for other cases ↵Miss Islington (bot)2024-05-222-341/+414
| | | | | | | (GH-118755) (cherry picked from commit b64182550f73e556344bd754d32e3be5d22a74e1) Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
* [3.13] gh-119049: Fix incorrect display of warning which is constructed by C ↵Miss Islington (bot)2024-05-171-0/+10
| | | | | | | | | 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>
* gh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (GH-119056)Miss Islington (bot)2024-05-151-1/+1
| | | | | (cherry picked from commit 94591dca510c796c7d40e9b4167ea56f2fdf28ca) Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.13] gh-118998: Handle errors correctly in `tmtotuple` in `timemodule` ↵Miss Islington (bot)2024-05-131-10/+17
| | | | | | | | (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>
* [3.13] gh-118895: Call PyType_Ready() on typing.NoDefault (GH-118897) (#118914)Miss Islington (bot)2024-05-101-0/+3
| | | | | (cherry picked from commit 13d7cf997bc9c22cf67c42fd799413e8325e0039) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-118209: Add Windows structured exception handling to mmap module (GH-118213)Miss Islington (bot)2024-05-101-48/+328
| | | | | (cherry picked from commit e85e8deaf3220c8d12b69294e45645aaf20187b9) Co-authored-by: Dobatymo <Dobatymo@users.noreply.github.com>
* [3.13] Revert "gh-115432: Add critical section variant that handles a NULL ↵Miss Islington (bot)2024-05-091-9/+0
| | | | | | | | | | 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-118773: Use language-invariant SDDL string instead of aliases for ACLs. ↵Miss Islington (bot)2024-05-091-154/+22
| | | | | | | (GH-118800) (cherry picked from commit 8af84b503d0b62a3db0d806d39f42c1e08746079) Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.13] gh-117657: Acquire a critical section around ↵Miss Islington (bot)2024-05-092-4/+14
| | | | | | | | | `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>
* gh-118671: Updated dead ActiveState links (#118730)trag1c2024-05-081-1/+1
| | | | | Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* bpo-115773: Use the right variable name based on the field we are trying ↵Abhinav Upadhyay2024-05-071-2/+2
| | | | | read (#118591) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* gh-66410: Do not stringify arguments of Tkinter callback (GH-98592)Serhiy Storchaka2024-05-072-11/+14
| | | | | | | | | 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.
* gh-118314: Fix padding edge case in binascii.a2b_base64 strict mode (GH-118320)Youfu Zhang2024-05-071-0/+7
| | | | | | | 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>
* gh-112075: use per-thread dict version pool (#118676)Dino Viehland2024-05-071-1/+13
| | | use thread state set of dict versions
* gh-118527: Intern code consts in free-threaded build (#118667)Sam Gross2024-05-071-0/+12
| | | | | | 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.
* gh-71592: Fix a leak in tkinter.Tk destructor when _debug is true (GH-118664)Serhiy Storchaka2024-05-061-0/+1
|
* gh-118362: Fix thread safety around lookups from the type cache in the face ↵Dino Viehland2024-05-064-6/+8
| | | | | | | 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
* gh-71592: Add ability to trace Tcl commands executed by Tkinter (GH-118291)Serhiy Storchaka2024-05-062-2/+175
| | | | | | | | | | | | 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-116322: Rename PyModule_ExperimentalSetGIL to PyUnstable_Module_SetGIL ↵Petr Viktorin2024-05-0613-15/+15
| | | | (GH-118645)
* gh-95382: Improve performance of json encoder with indent (GH-118105)Pieter Eendebak2024-05-061-40/+96
|
* gh-111201: A new Python REPL (GH-111567)Pablo Galindo Salgado2024-05-051-5/+16
| | | | | | | 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>
* gh-110850: Remove _PyTime_TimeUnchecked() function (#118552)Victor Stinner2024-05-052-5/+12
| | | | | | | | | | | | | 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()
* gh-109617: fix ncurses incompatibility on macOS with Xcode 15 (#111258)Davide Rizzo2024-05-041-4/+13
| | | | Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-111997: C-API for signalling monitoring events (#116413)Irit Katriel2024-05-044-1/+512
|
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-03102-32/+200
| | | | | | | | | | | | | | 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).
* gh-101732: Modules/_ssl.c: use Y2038 compatible openssl function when ↵Alexander Kanavin2024-05-031-0/+4
| | | | available (GH-118425)
* gh-116126: Implement PEP 696 (#116129)Jelle Zijlstra2024-05-031-0/+3
| | | | | 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>
* gh-117953: Other Cleanups in the Extensions Machinery (gh-118206)Eric Snow2024-05-031-1/+167
| | | This change will make some later changes simpler.