summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix typos in documentation and comments (#119763)Xie Yanbo2024-06-047-9/+9
|
* gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021)Victor Stinner2024-06-041-6/+6
| | | | Call _PyObject_DebugMallocStats() earlier in Py_FinalizeEx(), before the interpreter is deleted.
* gh-117398: Use Per-Interpreter State for the _datetime Static Types (gh-119929)Eric Snow2024-06-031-2/+2
| | | | | | | We make use of the same mechanism that we use for the static builtin types. This required a few tweaks. The relevant code could use some cleanup but I opted to avoid the significant churn in this change. I'll tackle that separately. This change is the final piece needed to make _datetime support multiple interpreters. I've updated the module slot accordingly.
* gh-117657: Fix race involving immortalizing objects (#119927)Sam Gross2024-06-033-13/+11
| | | | | | | | | 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.
* gh-117657: Avoid `sem_clockwait` in TSAN (#119915)Sam Gross2024-06-031-1/+1
| | | | The `sem_clockwait` function is not currently instrumented, which leads to false positives.
* gh-119981: Use do while(0) in some symtable.c multi-line macros (#119982)Bénédikt Tran2024-06-031-45/+52
|
* gh-117657: Fix TSAN race in QSBR assertion (#119887)Sam Gross2024-06-011-1/+2
| | | | Due to a limitation in TSAN, all reads from `PyThreadState.state` must be atomic to avoid reported races.
* gh-117657: Fix TSAN race in free-threaded GC (#119883)Sam Gross2024-06-011-3/+2
| | | | | Only call `gc_restore_tid()` from stop-the-world contexts. `worklist_pop()` can be called while other threads are running, so use a relaxed atomic to modify `ob_tid`.
* gh-74929: PEP 667 C API documentation (gh-119379)Alyssa Coghlan2024-06-014-4/+3
| | | | | | | | * Add docs for new APIs * Add soft-deprecation notices * Add What's New porting entries * Update comments referencing `PyFrame_LocalsToFast()` to mention the proxy instead * Other related cleanups found when looking for refs to the deprecated APIs
* gh-119821: Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS (#119822)Jelle Zijlstra2024-05-314-53/+54
| | | | | | | | | Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS The implementation basically copies LOAD_GLOBAL. Possibly it could be deduplicated, but that seems like it may get hairy since the two operations have different operands. This is important to fix in 3.14 for PEP 649, but it's a bug in earlier versions too, and we should backport to 3.13 and 3.12 if possible.
* gh-119369: Fix deadlock during thread exit in free-threaded build (#119528)Sam Gross2024-05-312-9/+17
| | | | | | | Release the GIL before calling `_Py_qsbr_unregister`. The deadlock could occur when the GIL was enabled at runtime. The `_Py_qsbr_unregister` call might block while holding the GIL because the thread state was not active, but the GIL was still held.
* gh-119585: Fix crash involving `PyGILState_Release()` and ↵Sam Gross2024-05-311-0/+6
| | | | | | | | | | `PyThreadState_Clear()` (#119753) 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.
* gh-119744: move a few functions from compile.c to flowgraph.c (#119745)Irit Katriel2024-05-302-151/+149
|
* gh-119689: generate stack effect metadata for pseudo instructions (#119691)Irit Katriel2024-05-292-51/+30
|
* gh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE (#119619)Sergey B Kirpichev2024-05-295-11/+11
|
* gh-119704: Fix reference leak in the ``Python/Python-tokenize.c`` (#119705)Kirill Podoprigora2024-05-291-0/+1
|
* GH-119258: Handle STORE_ATTR_WITH_HINT in tier two (GH-119481)Brandt Bucher2024-05-284-44/+115
|
* GH-119476: Split _CHECK_FUNCTION_VERSION out of _CHECK_FUNCTION_EXACT_ARGS ↵Brandt Bucher2024-05-285-21/+21
| | | | (GH-119510)
* gh-119118: Fix performance regression in tokenize module (#119615)Lysandros Nikolaou2024-05-281-4/+40
| | | | | | | | | | * gh-119118: Fix performance regression in tokenize module - Cache line object to avoid creating a Unicode object for all of the tokens in the same line. - Speed up byte offset to column offset conversion by using the smallest buffer possible to measure the difference. Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* gh-119676: remove several pseudo instructions which are use only in codegen ↵Irit Katriel2024-05-282-29/+5
| | | | (#119677)
* gh-117557: Improve error messages when a string, bytes or bytearray of ↵Serhiy Storchaka2024-05-281-4/+30
| | | | length 1 are expected (GH-117631)
* gh-119311: Fix name mangling with PEP 695 generic classes (#119464)Jelle Zijlstra2024-05-282-13/+48
| | | | Fixes #119311. Fixes #119395.
* gh-119584: Fix test_import Failed Assertion (gh-119623)Eric Snow2024-05-271-2/+2
| | | 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().
* gh-111997: Fix argument count for LINE event and clarify type of argument ↵scoder2024-05-261-10/+12
| | | | counts. (#119179)
* gh-119560: Drop an Invalid Assert in PyState_FindModule() (gh-119561)Eric Snow2024-05-251-2/+1
| | | 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.
* gh-118727: Don't drop the GIL in `drop_gil()` unless the current thread ↵Brett Simmers2024-05-232-46/+61
| | | | | | | | | | | | | | | | | holds it (#118745) `drop_gil()` assumes that its caller is attached, which means that the current thread holds the GIL if and only if the GIL is enabled, and the enabled-state of the GIL won't change. This isn't true, though, because `detach_thread()` calls `_PyEval_ReleaseLock()` after detaching and `_PyThreadState_DeleteCurrent()` calls it after removing the current thread from consideration for stop-the-world requests (effectively detaching it). Fix this by remembering whether or not a thread acquired the GIL when it last attached, in `PyThreadState._status.holds_gil`, and check this in `drop_gil()` instead of `gil->enabled`. This fixes a crash in `test_multiprocessing_pool_circular_import()`, so I've reenabled it.
* gh-119431: fix refleak in test_monitoring (#119444)Irit Katriel2024-05-231-0/+1
|
* gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters ↵Eric Snow2024-05-221-2/+19
| | | | | | | | | (gh-119331) _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.
* gh-119180: Add LOAD_COMMON_CONSTANT opcode (#119321)Jelle Zijlstra2024-05-226-18/+49
| | | | | | | | | | The PEP 649 implementation will require a way to load NotImplementedError from the bytecode. @markshannon suggested implementing this by converting LOAD_ASSERTION_ERROR into a more general mechanism for loading constants. This PR adds this new opcode. I will work on the rest of the implementation of the PEP separately. Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* gh-118692: Avoid creating unnecessary StopIteration instances for monitoring ↵Irit Katriel2024-05-214-18/+20
| | | | (#119216)
* gh-111389: Add PyHASH_MULTIPLIER constant (#119214)Victor Stinner2024-05-213-4/+4
|
* gh-119219: Remove two obsolete TODOs. (#119223)Jeremy Hylton2024-05-201-4/+0
| | | Remove two obsolete TODOs.
* gh-119132: Update sys.version to identify free-threaded or not. (gh-119134)Donghee Na2024-05-181-2/+7
|
* gh-119049: Fix incorrect display of warning which is constructed by C API ↵Kirill Podoprigora2024-05-161-3/+2
| | | | | | | (GH-119063) The source line was not displayed if the warnings module had not yet been imported.
* GH-118844: Fix build failures when combining --disable-gil with ↵Savannah Ostrowski2024-05-112-2/+3
| | | | --enable-experimental-jit (GH-118935)
* gh-118702: Implement vectorcall for BaseException (#118703)Victor Stinner2024-05-101-4/+5
| | | | | | | | | | * BaseException_vectorcall() now creates a tuple from 'args' array. * Creation an exception using BaseException_vectorcall() is now a single function call, rather than having to call BaseException_new() and then BaseException_init(). Calling BaseException_init() is inefficient since it overrides the 'args' attribute. * _PyErr_SetKeyError() now uses PyObject_CallOneArg() to create the KeyError instance to use BaseException_vectorcall().
* GH-118910: Less boilerplate in the tier 2 optimizer (#118913)Mark Shannon2024-05-104-462/+267
|
* gh-118771: Ensure names defined in optimizer.h start with Py/_Py (GH-118825)Petr Viktorin2024-05-101-4/+4
|
* gh-117657: Fix QSBR race condition (#118843)Alex Turner2024-05-102-6/+7
| | | | | | `_Py_qsbr_unregister` is called when the PyThreadState is already detached, so the access to `tstate->qsbr` isn't safe without locking the shared mutex. Grab the `struct _qsbr_shared` from the interpreter instead.
* gh-117657: Fix data races reported by TSAN on `interp->threads.main` (#118865)mpage2024-05-101-11/+20
| | | Use relaxed loads/stores when reading/writing to this field.
* gh-118851: Default ctx arguments to AST constructors to Load() (#118854)Jelle Zijlstra2024-05-091-0/+7
| | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-118518: Rename `PYTHONPERFJITSUPPORT` and `-X perfjit` with underscores ↵Hugo van Kemenade2024-05-072-3/+3
| | | | (#118693)
* gh-118414: Fix assertion in YIELD_VALUE when tracing lines or instrs (#118683)Tian Gao2024-05-073-3/+9
|
* gh-117953: Always Run Extension Init Func in Main Interpreter First (gh-118157)Eric Snow2024-05-071-55/+197
| | | This change makes sure all extension/builtin modules have their init function run first by the main interpreter before proceeding with import in the original interpreter (main or otherwise). This means when the import of a single-phase init module fails in an isolated subinterpreter, it won't tie any global state/callbacks to the subinterpreter.
* gh-117953: Imply Single-phase Init if the Init Function Fails (gh-118684)Eric Snow2024-05-071-0/+7
| | | This ensures the kind is always either _Py_ext_module_kind_SINGLEPHASE or _Py_ext_module_kind_MULTIPHASE.
* gh-116322: Enable the GIL while loading C extension modules (#118560)Brett Simmers2024-05-074-26/+269
| | | | | | | | | | Add the ability to enable/disable the GIL at runtime, and use that in the C module loading code. We can't know before running a module init function if it supports free-threading, so the GIL is temporarily enabled before doing so. If the module declares support for running without the GIL, the GIL is later disabled. Otherwise, the GIL is permanently enabled, and will never be disabled again for the life of the current interpreter.
* gh-112075: use per-thread dict version pool (#118676)Dino Viehland2024-05-071-0/+1
| | | use thread state set of dict versions
* gh-118527: Intern code consts in free-threaded build (#118667)Sam Gross2024-05-073-0/+21
| | | | | | 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-118473: Fix set_asyncgen_hooks not to be partially set when arguments are ↵Jeong, YunWon2024-05-071-8/+20
| | | | invalid (#118474)
* gh-117486: Improve behavior for user-defined AST subclasses (#118212)Jelle Zijlstra2024-05-061-14/+17
| | | | | | | | Now, such classes will no longer require changes in Python 3.13 in the normal case. The test suite for robotframework passes with no DeprecationWarnings under this PR. I also added a new DeprecationWarning for the case where `_field_types` exists but is incomplete, since that seems likely to indicate a user mistake.