summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* gh-121153: Fix some errors with use of _PyLong_CompactValue() (GH-121154)Serhiy Storchaka2024-07-131-2/+2
| | | | | | * The result has type Py_ssize_t, not intptr_t. * Type cast between unsigned and signdet integer types should be explicit. * Downcasting should be explicit. * Fix integer overflow check in sum().
* gh-121332: Make AST node constructor check _attributes instead of hardcoding ↵Jelle Zijlstra2024-07-111-14/+25
| | | | attributes (#121334)
* gh-121554: remove unnecessary internal functions in compile.c (#121555)Irit Katriel2024-07-101-48/+0
| | | Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-121404: remove some accesses to compiler internals from codegen functions ↵Irit Katriel2024-07-101-101/+120
| | | | (#121538)
* gh-121547: deduplicate the code of const_cache update functions (#121548)Irit Katriel2024-07-101-25/+22
|
* gh-121110: Fix Extension Module Tests Under Py_TRACE_REFS Builds (gh-121503)Eric Snow2024-07-081-19/+43
| | | The change in gh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't. We fix that here. Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests.
* gh-121404: remove direct accesses to u_private from codegen functions (#121500)Irit Katriel2024-07-081-27/+42
|
* gh-121368: Fix seq lock memory ordering in _PyType_Lookup (#121388)Sam Gross2024-07-081-11/+15
| | | | | | | | | 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.
* GH-121012: Set index to -1 when list iterators become exhausted in tier 2 ↵Mark Shannon2024-07-082-3/+9
| | | | (GH-121483)
* gh-121338: Remove #pragma optimize (#121340)Michael Droettboom2024-07-081-10/+0
|
* gh-121149: improve accuracy of builtin sum() for complex inputs (gh-121176)Sergey B Kirpichev2024-07-051-26/+105
|
* gh-121390: tracemalloc: Fix tracebacks memory leak (#121391)Josh Brobst2024-07-051-1/+1
| | | | | | The tracemalloc_tracebacks hash table has traceback keys and NULL values, but its destructors do not reflect this -- key_destroy_func is NULL while value_destroy_func is raw_free. Swap these to free the traceback keys instead.
* gh-121272: move async for/with validation from compiler to symtable (#121361)Irit Katriel2024-07-042-13/+22
|
* gh-121352: use _Py_SourceLocation in symtable (#121353)Irit Katriel2024-07-041-127/+68
|
* gh-121141: add support for `copy.replace` to AST nodes (#121162)Bénédikt Tran2024-07-041-0/+279
|
* gh-121272: set ste_coroutine during symtable construction (#121297)Irit Katriel2024-07-032-3/+15
| | | compiler no longer modifies the symtable after this.
* gh-117139: Add _PyTuple_FromStackRefSteal and use it (#121244)Sam Gross2024-07-024-32/+4
| | | Avoids the extra conversion from stack refs to PyObjects.
* gh-121272: move __future__ import validation from compiler to symtable (#121273)Irit Katriel2024-07-022-16/+24
|
* GH-116017: Get rid of _COLD_EXITs (GH-120960)Brandt Bucher2024-07-017-183/+121
|
* gh-121199: Use _Py__has_attribute() in timemodule.c (#121203)Victor Stinner2024-07-011-1/+1
| | | | | Use the _Py__has_attribute() macro in timemodule.c and bootstrap_hash.c to fix a build error on old GCC versions (GCC 4.8.5 on s390x).
* gh-121163: Add "all" as an valid alias for "always" in ↵Kirill Podoprigora2024-06-301-2/+2
| | | | | | warnings.simplefilter() (#121164) Add support for ``all`` as an valid alias for ``always`` in ``warnings.simplefilter()`` and ``warnings.filterswarnings()``.
* gh-117139: Fix a few wrong steals in bytecodes.c (GH-121127)Ken Jin2024-06-284-33/+33
| | | Fix a few wrong steals in bytecodes.c
* gh-120837: Update _Py_DumpExtensionModules to be async-signal-safe (gh-121051)Donghee Na2024-06-271-2/+36
|
* gh-121082: Fix build failure when the developer use `--enable-pystats` ↵Nadeshiko Manju2024-06-271-2/+3
| | | | | | | | arguments in configuration command after #118450 (#121083) Signed-off-by: Manjusaka <me@manjusaka.me> Co-authored-by: Ken Jin <kenjin4096@gmail.com>
* gh-121040: Use __attribute__((fallthrough)) (#121044)Victor Stinner2024-06-2713-55/+56
| | | | | | | | | | | | | Fix warnings when using -Wimplicit-fallthrough compiler flag. Annotate explicitly "fall through" switch cases with a new _Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if available. Replace "fall through" comments with _Py_FALLTHROUGH. Add _Py__has_attribute() macro. No longer define __has_attribute() macro if it's not defined. Move also _Py__has_builtin() at the top of pyport.h. Co-Authored-By: Nikita Sobolev <mail@sobolevn.me>
* gh-113433: Automatically Clean Up Subinterpreters in Py_Finalize() (gh-121060)Eric Snow2024-06-261-9/+147
| | | This change makes things a little less painful for some users. It also fixes a failing assert (gh-120765), by making sure all subinterpreters are destroyed before the main interpreter. As part of that, we make sure Py_Finalize() always runs with the main interpreter active.
* gh-117139: Convert the evaluation stack to stack refs (#118450)Ken Jin2024-06-269-3482/+4811
| | | | | | | | | | | | | | | | | This PR sets up tagged pointers for CPython. The general idea is to create a separate struct _PyStackRef for everything on the evaluation stack to store the bits. This forces the C compiler to warn us if we try to cast things or pull things out of the struct directly. Only for free threading: We tag the low bit if something is deferred - that means we skip incref and decref operations on it. This behavior may change in the future if Mark's plans to defer all objects in the interpreter loop pans out. This implies a strict stack reference discipline is required. ALL incref and decref operations on stackrefs must use the stackref variants. It is unsafe to untag something then do normal incref/decref ops on it. The new incref and decref variants are called dup and close. They mimic a "handle" API operating on these stackrefs. Please read Include/internal/pycore_stackref.h for more information! --------- Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
* gh-120642: Move private PyCode APIs to the internal C API (#120643)Victor Stinner2024-06-264-23/+7
| | | | | | | | | | | | | | | * 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()
* gh-120838: Add _PyThreadState_WHENCE_FINI (gh-121010)Eric Snow2024-06-254-13/+15
| | | | | We also add _PyThreadState_NewBound() and drop _PyThreadState_SetWhence(). This change only affects internal API.
* GH-120982: Add stack check assertions to generated interpreter code (GH-120992)Mark Shannon2024-06-255-0/+430
|
* gh-120108: Fix deepcopying of AST trees with .parent attributes (#120114)Jelle Zijlstra2024-06-251-17/+14
|
* Fixes loop variables to be the same types as their limit (GH-120958)Steve Dower2024-06-247-15/+16
|
* GH-117062: Make _JUMP_TO_TOP a general absolute jump (GH-120854)Brandt Bucher2024-06-243-6/+7
|
* gh-120834: fix type of *_iframe field in _PyGenObject_HEAD declaration (#120835)Irit Katriel2024-06-246-18/+17
|
* gh-119344: Make critical section API public (#119353)Sam Gross2024-06-211-29/+77
| | | | | | | | | | 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.
* gh-120811: Fix reference leak upon `_PyContext_Exit` failure (#120812)Peter2024-06-211-0/+1
| | | Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* gh-113993: Allow interned strings to be mortal, and fix related issues ↵Petr Viktorin2024-06-219-34/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-120520) * 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>
* gh-119182: Use public PyUnicodeWriter in contextvar_tp_repr() (#120809)Victor Stinner2024-06-201-32/+15
| | | | The public PyUnicodeWriter API enables overallocation by default and so is more efficient. It also makes the code simpler and shorter.
* gh-117511: Make PyMutex public in the non-limited API (#117731)Sam Gross2024-06-202-26/+28
|
* gh-98442: fix locations of with statement's cleanup instructions (#120763)Irit Katriel2024-06-201-1/+3
| | | gh-98442: fix location of with statement's cleanup instructions
* Fix typos in comments (#120481)Xie Yanbo2024-06-202-3/+3
|
* gh-120437: Fix `_CHECK_STACK_SPACE` optimization problems introduced in ↵Nadeshiko Manju2024-06-192-2/+0
| | | | | | gh-118322 (GH-120712) Co-authored-by: Ken Jin <kenjin4096@gmail.com>
* gh-120733: rename internal compiler functions according to naming convention ↵Irit Katriel2024-06-191-30/+23
| | | | (#120734)
* gh-120722: Set position on RETURN_VALUE in lambda (#120724)Jelle Zijlstra2024-06-191-1/+1
|
* gh-120726: Fix compiler warnings on is_core_module() (#120727)Kirill Podoprigora2024-06-192-4/+5
| | | | | Fix compiler warnings on is_core_module() and check_interpreter_whence(): only define them when assertions are built.
* gh-120367: fix bug where compiler detects redundant jump after pseudo op ↵Irit Katriel2024-06-181-1/+1
| | | | replacement (#120714)
* gh-119574: Add some missing environment variables to '--help-env'. (GH-120006)devdanzin2024-06-181-0/+17
|
* GH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` instructions. ↵Mark Shannon2024-06-188-179/+141
| | | | | | | | | (#120640) * Remove BEFORE_WITH and BEFORE_ASYNC_WITH instructions. * Add LOAD_SPECIAL instruction * Reimplement `with` and `async with` statements using LOAD_SPECIAL
* gh-117657: Fix `__slots__` thread safety in free-threaded build (#119368)Daniele Parmeggiani2024-06-171-9/+33
| | | | Fix a race in `PyMember_GetOne` and `PyMember_SetOne` for `Py_T_OBJECT_EX`. These functions implement `__slots__` accesses for Python objects.
* gh-117657: Fix TSan reported data race on ioctl_works (#120175)Sam Gross2024-06-171-3/+5
|