summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* gh-126171: fix possible null dereference in _imp_find_frozen_impl (#126566)Valery Fedorenko2024-11-081-1/+1
|
* gh-122943: Remove the object converter for var-positional parameter (GH-126560)Serhiy Storchaka2024-11-082-19/+16
|
* gh-120017: use 'do-while(0)' in some `{codegen,compile}.c` multi-line macros ↵Bénédikt Tran2024-11-072-62/+72
| | | | (#120018)
* gh-122943: Rework support of var-positional parameter in Argument Clinic ↵Serhiy Storchaka2024-11-072-171/+28
| | | | | | | | | | | | | | | | | | (GH-122945) Move creation of a tuple for var-positional parameter out of _PyArg_UnpackKeywordsWithVararg(). Merge _PyArg_UnpackKeywordsWithVararg() with _PyArg_UnpackKeywords(). Add a new parameter in _PyArg_UnpackKeywords(). The "parameters" and "converters" attributes of ParseArgsCodeGen no longer contain the var-positional parameter. It is now available as the "varpos" attribute. Optimize code generation for var-positional parameter and reuse the same generating code for functions with and without keyword parameters. Add special converters for var-positional parameter. "tuple" represents it as a Python tuple and "array" represents it as a continuous array of PyObject*. "object" is a temporary alias of "tuple".
* gh-76785: Minor Cleanup of "Cross-interpreter" Code (gh-126457)Eric Snow2024-11-073-170/+169
| | | | | | | | The primary objective here is to allow some later changes to be cleaner. Mostly this involves renaming things and moving a few things around. * CrossInterpreterData -> XIData * crossinterpdatafunc -> xidatafunc * split out pycore_crossinterp_data_registry.h * add _PyXIData_lookup_t
* Chore: Fix typo in `pyarena.c` (#126527)Aditya Borikar2024-11-071-1/+1
|
* gh-126513: Use helpers for `_Py_Specialize_ConstainsOp` (#126517)Kirill Podoprigora2024-11-061-17/+7
| | | | | * Use helpers for _Py_Specialize_ConstainsOp * Remove unnecessary variable
* gh-115999: Introduce helpers for (un)specializing instructions (#126414)mpage2024-11-061-48/+84
| | | | | | | | Introduce helpers for (un)specializing instructions Consolidate the code to specialize/unspecialize instructions into two helper functions and use them in `_Py_Specialize_BinaryOp`. The resulting code is more concise and keeps all of the logic at the point where we decide to specialize/unspecialize an instruction.
* gh-115999: Add free-threaded specialization for CONTAINS_OP (gh-126450)Donghee Na2024-11-063-6/+8
| | | | - The specialization logic determines the appropriate specialization using only the operand's type, which is safe to read non-atomically (changing it requires stopping the world). We are guaranteed that the type will not change in between when it is checked and when we specialize the bytecode because the types involved are immutable (you cannot assign to `__class__` for exact instances of `dict`, `set`, or `frozenset`). The bytecode is mutated atomically using helpers. - The specialized instructions rely on the operand type not changing in between the `DEOPT_IF` checks and the calls to the appropriate type-specific helpers (e.g. `_PySet_Contains`). This is a correctness requirement in the default builds and there are no changes to the opcodes in the free-threaded builds that would invalidate this.
* GH-125911: Rename big trampoline to "shim" (GH-126339)Savannah Ostrowski2024-11-051-7/+5
|
* gh-126238: Fix possible null pointer dereference of freevars in ↵Valery Fedorenko2024-11-051-1/+1
| | | | | | | | _PyCompile_LookupArg (#126239) * Replace Py_DECREF by Py_XDECREF Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* gh-126366: Fix crash if `__iter__` raises an exception during `yield from` ↵Peter Bierma2024-11-053-6/+9
| | | | (#126369)
* gh-126415: Fix conversion warning in `Python/bytecodes.c` (#126416)Kirill Podoprigora2024-11-052-3/+3
| | | | | Fix conversion warning in bytecodes Co-authored-by: mpage <mpage@cs.stanford.edu>
* gh-115999: Implement thread-local bytecode and enable specialization for ↵mpage2024-11-0414-167/+570
| | | | | | | | | `BINARY_OP` (#123926) Each thread specializes a thread-local copy of the bytecode, created on the first RESUME, in free-threaded builds. All copies of the bytecode for a code object are stored in the co_tlbc array on the code object. Threads reserve a globally unique index identifying its copy of the bytecode in all co_tlbc arrays at thread creation and release the index at thread destruction. The first entry in every co_tlbc array always points to the "main" copy of the bytecode that is stored at the end of the code object. This ensures that no bytecode is copied for programs that do not use threads. Thread-local bytecode can be disabled at runtime by providing either -X tlbc=0 or PYTHON_TLBC=0. Disabling thread-local bytecode also disables specialization. Concurrent modifications to the bytecode made by the specializing interpreter and instrumentation use atomics, with specialization taking care not to overwrite an instruction that was instrumented concurrently.
* gh-119793: Add optional length-checking to `map()` (GH-120471)Nice Zombies2024-11-041-12/+88
| | | | | | Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* gh-125832: Reformat comments for inlined comprehensions (gh-126346)Donghee Na2024-11-031-5/+5
|
* gh-125832: Clarify comment for inlined comprehensions as per PEP-709 (#126322)rimchoi2024-11-021-3/+6
| | | | | | | | | | | | | | * Fix comprehensions comment to inlined by pep 709 * Update spacing Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com> * Add reference to PEP 709 --------- Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com>
* gh-126255: Ignore warning about JIT being deactivated when perf support is ↵mpage2024-11-012-1/+7
| | | | | | | | | | | active in `test_embed.InitConfigTests.test_initconfig_api` (#126302) Temporarily ignore warnings about JIT deactivation when perf support is active. This will be reverted as soon as a way is found to determine at run time whether the interpreter was built with JIT. Currently, this is not possible on Windows. Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* gh-120026: soft deprecate Py_HUGE_VAL macro (#120027)Sergey B Kirpichev2024-11-011-2/+2
| | | Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* gh-126072: do not add `None` to `co_consts` if there is no docstring (GH-126101)Xuanteng Huang2024-10-303-3/+15
|
* gh-124855: Don't allow the JIT and perf support to be active at the same ↵Pablo Galindo Salgado2024-10-302-7/+22
| | | | time (#124856)
* gh-126139: Improve error message location for future statement with unknown ↵Brian Schubert2024-10-291-2/+10
| | | | feature (#126140)
* gh-118423: Add `INSTRUCTION_SIZE` macro to code generator (GH-125467)Tomas R.2024-10-293-28/+28
|
* gh-126105: Fix crash in `ast` module, when `._fields` is deleted (#126115)sobolevn2024-10-291-10/+8
| | | | Previously, if the `ast.AST._fields` attribute was deleted, attempts to create a new `as`t node would crash due to the assumption that `_fields` always had a non-NULL value. Now it has been fixed by adding an extra check to ensure that `_fields` does not have a NULL value (this can happen when you manually remove `_fields` attribute).
* GH-125837: Split `LOAD_CONST` into three. (GH-125972)Mark Shannon2024-10-2910-139/+204
| | | | | | | | * Add LOAD_CONST_IMMORTAL opcode * Add LOAD_SMALL_INT opcode * Remove RETURN_CONST opcode
* GH-125912: Teach the JIT's optimizer about _BINARY_OP_INPLACE_ADD_UNICODE ↵Brandt Bucher2024-10-282-0/+37
| | | | (GH-125935)
* GH-125515: Reduce number of compiler warnings in generated code (GH-125697)Mark Shannon2024-10-282-5/+7
|
* gh-126018: Avoid aborting due to unnecessary assert in `sys.audit` (#126020)devdanzin2024-10-271-1/+0
| | | | Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* GH-125911: Call combine_symbol_mask on the initial trampoline of a trace ↵Nadeshiko Manju2024-10-251-0/+1
| | | | (GH-125973)
* gh-125900: Clean-up logic around immortalization in free-threading (#125901)Sam Gross2024-10-241-5/+13
| | | | | | | | | * Remove `@suppress_immortalization` decorator * Make suppression flag per-thread instead of per-interpreter * Suppress immortalization in `eval()` to avoid refleaks in three tests (test_datetime.test_roundtrip, test_logging.test_config8_ok, and test_random.test_after_fork). * frozenset() is constant, but not a singleton. When run multiple times, the test could fail due to constant interning.
* gh-123930: Better error for "from imports" when script shadows module (#123929)Shantanu2024-10-241-47/+103
|
* gh-124218: Avoid refcount contention on builtins module (GH-125847)Sam Gross2024-10-241-2/+4
| | | | | | | This replaces `_PyEval_BuiltinsFromGlobals` with `_PyDict_LoadBuiltinsFromGlobals`, which returns a new reference instead of a borrowed reference. Internally, the new function uses per-thread reference counting when possible to avoid contention on the refcount fields on the builtins module.
* gh-125842: Fix `sys.exit(0xffff_ffff)` on Windows (#125896)Sam Gross2024-10-241-33/+47
| | | | | | | | | | On Windows, `long` is a signed 32-bit integer so it can't represent `0xffff_ffff` without overflow. Windows exit codes are unsigned 32-bit integers, so if a child process exits with `-1`, it will be represented as `0xffff_ffff`. Also fix a number of other possible cases where `_Py_HandleSystemExit` could return with an exception set, leading to a `SystemError` (or fatal error in debug builds) later on during shutdown.
* gh-125859: Fix crash when `gc.get_objects` is called during GC (#125882)Sam Gross2024-10-241-73/+64
| | | | | | | | | 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.
* GH-125868: Fix STORE_ATTR_WITH_HINT specialization (GH-125876)Mark Shannon2024-10-243-12/+12
|
* gh-125286: Share the Main Refchain With Legacy Interpreters (gh-125709)Eric Snow2024-10-232-4/+16
| | | | | They used to be shared, before 3.12. Returning to sharing them resolves a failure on Py_TRACE_REFS builds. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-125038: Fix crash after genexpr.gi_frame.f_locals manipulations (#125178)Mikhail Efimov2024-10-221-0/+1
|
* GH-125521: Remove `if (true)` from generated output to reduce C compiler ↵Mark Shannon2024-10-221-34/+34
| | | | warnings (GH-125700)
* gh-121459: Fix a couple of uses of `PyStackRef_FromPyObjectSteal` (#125711)mpage2024-10-213-12/+18
| | | | | | | | | | | * Fix usage of PyStackRef_FromPyObjectSteal in CALL_TUPLE_1 This was missed in gh-124894 * Fix usage of PyStackRef_FromPyObjectSteal in _CALL_STR_1 This was missed in gh-124894 * Regenerate code
* gh-124218: Use per-thread reference counting for globals and builtins (#125713)Sam Gross2024-10-211-3/+9
| | | | Use per-thread refcounting for the reference from function objects to the globals and builtins dictionaries.
* gh-125703: Correctly honour tracemalloc hooks on more PyDECREF specialized ↵Pablo Galindo Salgado2024-10-211-0/+5
| | | | paths (#125712)
* gh-125207: Fix MSVC 1935 build with JIT (#125209)Michael Droettboom2024-10-181-1/+1
| | | | | | | * gh-125207: Use {0} array initializers * Simplify, as suggested in PR * Revert change to explicitly specify length
* gh-125604: Move _Py_AuditHookEntry, etc. Out of pycore_runtime.h (gh-125605)Eric Snow2024-10-189-8/+15
| | | | | | | | | | | | This is essentially a cleanup, moving a handful of API declarations to the header files where they fit best, creating new ones when needed. We do the following: * add pycore_debug_offsets.h and move _Py_DebugOffsets, etc. there * inline struct _getargs_runtime_state and struct _gilstate_runtime_state in _PyRuntimeState * move struct _reftracer_runtime_state to the existing pycore_object_state.h * add pycore_audit.h and move to it _Py_AuditHookEntry , _PySys_Audit(), and _PySys_ClearAuditHooks * add audit.h and cpython/audit.h and move the existing audit-related API there *move the perfmap/trampoline API from cpython/sysmodule.h to cpython/ceval.h, and remove the now-empty cpython/sysmodule.h
* gh-125541: Make Ctrl-C interrupt `threading.Lock.acquire()` on Windows (#125546)Sam Gross2024-10-171-2/+15
|
* gh-123153: Fix PGO builds with free-threading on Windows (#125607)Michael Droettboom2024-10-171-6/+14
| | | | | * gh-123153: Fix PGO builds with free-threading * Redo how the #define works
* gh-125217: Turn off optimization around_PyEval_EvalFrameDefault to avoid ↵Michael Droettboom2024-10-161-0/+14
| | | | MSVC crash (#125477)
* gh-124872: Replace enter/exit events with "switched" (#125532)Kirill Podoprigora2024-10-161-10/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Users want to know when the current context switches to a different context object. Right now this happens when and only when a context is entered or exited, so the enter and exit events are synonymous with "switched". However, if the changes proposed for gh-99633 are implemented, the current context will also switch for reasons other than context enter or exit. Since users actually care about context switches and not enter or exit, replace the enter and exit events with a single switched event. The former exit event was emitted just before exiting the context. The new switched event is emitted after the context is exited to match the semantics users expect of an event with a past-tense name. If users need the ability to clean up before the switch takes effect, another event type can be added in the future. It is not added here because YAGNI. I skipped 0 in the enum as a matter of practice. Skipping 0 makes it easier to troubleshoot when code forgets to set zeroed memory, and it aligns with best practices for other tools (e.g., https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum). Co-authored-by: Richard Hansen <rhansen@rhansen.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-124218: Use per-thread refcounts for code objects (#125216)Sam Gross2024-10-154-35/+49
| | | | | | | Use per-thread refcounting for the reference from function objects to their corresponding code object. This can be a source of contention when frequently creating nested functions. Deferred refcounting alone isn't a great fit here because these references are on the heap and may be modified by other libraries.
* gh-124375: Avoid calling `_PyMem_ProcessDelayed` on other thread states ↵Sam Gross2024-10-151-6/+12
| | | | | | | | | | | (#124459) This fixes a crash when running the PyO3 test suite on the free-threaded build. The `qsbr` field is initialized after the `PyThreadState` is added to the interpreter's linked list -- it might still be NULL. Instead, we "steal" the queue of to-be-freed memory blocks. This is always initialized (possibly empty) and protected by the stop the world pause.
* gh-125512: Revert "gh-124872: Replace enter/exit events with "switched" ↵Kirill Podoprigora2024-10-151-21/+10
| | | | (#124776)" (#125513)