Commit Graph

9614 Commits

Author SHA1 Message Date
Jelle Zijlstra
01317bb449 gh-132479: Fix crash with multiple comprehensions in annotations (#132778) 2025-04-21 13:49:59 -07:00
Sam Gross
da53660f35 gh-131586: Avoid refcount contention in context managers (gh-131851)
This avoid reference count contention in the free threading build
when calling special methods like `__enter__` and `__exit__`.
2025-04-21 15:54:25 -04:00
Peter Bierma
8dfa840773 gh-127604: Add C stack dumps to faulthandler (#128159) 2025-04-21 20:48:02 +01:00
Brandt Bucher
4f7f72ce34 GH-130415: Improve the JIT's unneeded uop removal pass (GH-132333) 2025-04-21 09:58:55 -07:00
Bénédikt Tran
427e7fc099 gh-132399: ensure correct alignment of PyInterpreterState (#132428) 2025-04-19 11:03:06 +02:00
Bénédikt Tran
8a9c6c4d16 gh-128398: improve error messages when incorrectly using with and async with (#132218)
Improve the error message with a suggestion when an object supporting the synchronous
(resp. asynchronous) context manager protocol is entered using `async with` (resp. `with`)
instead of `with` (resp. `async with`).
2025-04-19 10:44:01 +02:00
Pablo Galindo Salgado
c9a855a9e0 gh-131591: Execute the source and not the file to avoid locking it in Windows (#132712)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-04-19 00:38:12 +00:00
Kumar Aditya
7fd708b727 gh-132685: fix thread safety of PyMember_GetOne with _Py_T_OBJECT (#132690) 2025-04-18 21:03:42 +05:30
Brandt Bucher
40ae88988c GH-131498: Replace single-element arrays with scalars in bytecodes.c (GH-132615) 2025-04-18 07:16:28 -07:00
Bénédikt Tran
379352620c gh-132097: use a macro for semantically casting function pointers (#132406) 2025-04-18 12:24:34 +02:00
Kumar Aditya
f3d877a27a gh-132643: use atomic load for dict in specializer (#132653) 2025-04-18 15:06:27 +05:30
Adam Turner
ea23c897cd Remove duplicate includes: Python/importdl.c (#132623) 2025-04-18 02:49:19 +01:00
Alper
22830103e5 gh-131173: Improve exception handling during take_ownership processing (#132620)
Save and restore exceptions during take_ownership processing to preserve
exceptions currently being raised.

Co-authored-by: alperyoney <alperyoney@fb.com>
2025-04-17 13:38:34 -07:00
Bartosz Sławecki
954b2cf031 gh-130070: Fix exec(<string>, closure=<non-None>) unexpected path (#130071)
Fixed an assertion error (so, it could be reproduced only in builds with assertions enabled)
for `exec` when the `source` argument is a string and the `closure` argument is not `None`.

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-04-17 10:14:55 +03:00
Adam Turner
d7df7815f5 Remove duplicate includes: Python/ast_opt.c (#132621) 2025-04-17 10:10:01 +03:00
Nadeshiko Manju
b9e88ff4cb gh-131798: Use sym_new_type instead of sym_new_not_null for _BUILD_LIST, _BUILD_SLICE, and _BUILD_MAP (GH-132434)
---------

Signed-off-by: Manjusaka <me@manjusaka.me>
2025-04-17 01:17:48 +08:00
T. Wouters
c66ffcf8e3 gh-129987: Selectively re-enable SLP autovectorization of _PyEval_EvalFrameDefault (#132530)
Only disable SLP autovectorization of `_PyEval_EvalFrameDefault` on newer
GCCs, as the optimization bug seems to exist only on GCC 12 and later, and
before GCC 9 disabling the optimization has a dramatic performance impact.
2025-04-15 09:39:32 +00:00
Serhiy Storchaka
102f825c51 gh-124476: Fix decoding from the locale encoding in the C.UTF-8 locale (GH-132477) 2025-04-14 21:32:41 +03:00
Mark Shannon
844596c09f GH-131498: Cases generator: Allow input and 'peek' variables to be modified (GH-132506) 2025-04-14 12:19:53 +01:00
Furkan Onder
c7f6535e4a gh-131624: Fix posix_spawn tests failing on NetBSD with stack limit assertions (GH-131625)
Fix recursive limit assertions on NetBSD for posix_spawn.
2025-04-13 14:06:38 +03:00
Tomas R.
3d08c8ad20 gh-131927: Prevent emitting optimizer warnings twice in the REPL (#131993) 2025-04-12 11:34:36 +01:00
Serhiy Storchaka
d4e2cdc15b gh-125434: Fix building on OpenBSD (GH-132393)
pthread_get_name_np is defined in pthread_np.h.
2025-04-12 11:25:35 +03:00
Bénédikt Tran
a81232c769 gh-132399: fix invalid function signatures on the free-threaded build (#132400) 2025-04-12 07:46:33 +00:00
Tomas R.
e6ef47ac22 gh-132386: Fix a crash when passing a dict subclass to exec (GH-132412)
* Fix crash when passing a dict subclass to exec

* Add news entry
2025-04-12 05:05:03 +08:00
Mark Shannon
d87e7f3529 GH-127682: Only call __iter__ once in generator expressions. (GH-132351) 2025-04-11 09:37:22 +01:00
Jelle Zijlstra
07b8d3117f gh-132261: Store annotations at hidden internal keys in the class dict (#132345) 2025-04-10 21:13:26 -07:00
Chris Eibl
e5f68fd29b GH-131296: Suppress "unused label" warning for clang-cl closer to actual occurrence (GH-131900) 2025-04-10 23:17:33 +01:00
Chu
3d83c1ec61 Fix a typo in Python/pylifecycle.c (#132350) 2025-04-10 17:27:37 +05:30
mpage
619edb802e gh-132336: Mark a few "slow path" functions used by the interpreter loop as noinline (#132337)
Mark a few functions used by the interpreter loop as noinline

These are all the slow path and should not be inlined into the interpreter
loop. Unfortunately, they end up being inlined with LTO and the current PGO
task.
2025-04-10 10:41:15 +02:00
Neil Schemenauer
d687900f98 gh-128384: Use a context variable for warnings.catch_warnings (gh-130010)
Make `warnings.catch_warnings()` use a context variable for holding
the warning filtering state if the `sys.flags.context_aware_warnings`
flag is set to true.  This makes using the context manager thread-safe in
multi-threaded programs.

Add the `sys.flags.thread_inherit_context` flag.  If true, starting a new
thread with `threading.Thread` will use a copy of the context
from the caller of `Thread.start()`.

Both these flags are set to true by default for the free-threaded build
and false for the default build.

Move the Python implementation of warnings.py into _py_warnings.py.

Make _contextvars a builtin module.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-04-09 16:18:54 -07:00
Brandt Bucher
20926c73b5 GH-131798: Remove JIT guards for dict, frozenset, list, set, and tuple (GH-132289) 2025-04-09 14:32:21 -07:00
mpage
1f5682f3a2 gh-129987: Disable GCC SLP autovectorization for the interpreter loop on x86-64 (#132295)
The SLP autovectorizer can cause poor code generation for opcode dispatch, negating any benefit we get from vectorization elsewhere in the interpreter loop.
2025-04-09 10:34:12 -07:00
Serhiy Storchaka
f5f1ac84b3 gh-112068: C API: Add support of nullable arguments in PyArg_Parse (GH-121303) 2025-04-08 22:08:00 +03:00
Nadeshiko Manju
d753d8aed7 GH-131798: Narrow the result of _CONTAINS_OP_DICT to bool in the JIT (GH-132269)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-04-08 09:12:09 -07:00
Tomas R.
71009cb835 GH-131798: Narrow the result type of _BINARY_OP_SUBSCR_STR_INT to str in the JIT (GH-132153) 2025-04-08 08:22:54 -07:00
Serhiy Storchaka
0e4cf9ce7c gh-50333: Deprecate support of non-tuple sequences in PyArg_ParseTuple() (GH-128374)
Non-tuple sequences are deprecated as argument for the "(items)" format unit
in PyArg_ParseTuple() and other argument parsing functions if items contains
format units which store borrowed buffer or reference (e.g. "s" and "O").

str and bytearray are no longer accepted as valid sequences.
2025-04-08 14:26:32 +03:00
Peter Bierma
ac3c439cdf gh-131998: Fix NULL dereference when using an unbound method descriptor in a specialized code path (#132000)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Mark Shannon <mark@hotpy.org>
2025-04-08 10:31:43 +00:00
Irit Katriel
8c9ef8f1f8 gh-100239: more stats for BINARY_OP/SUBSCR specialization (#132230) 2025-04-08 08:50:51 +00:00
sobolevn
bc5233b6a5 gh-130775: Allow negative locations in ast (#130795)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-04-07 19:35:17 +03:00
Pablo Galindo Salgado
2067378e6d gh-131591: Handle includes for iOS in remote_debugging.c (#132050) 2025-04-06 21:39:25 +01:00
sobolevn
c0661df42a gh-132011: Fix crash on invalid CALL_LIST_APPEND deoptimization (#132018)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-04-06 19:10:39 +03:00
Tomas R.
85bc489b64 GH-131798: Narrow the result of _CONTAINS_OP_SET to bool in the JIT (GH-132057) 2025-04-05 15:56:01 -07:00
Adam Turner
231a50fa9a gh-109599: Expose CapsuleType via the _types module (#131969) 2025-04-04 23:37:41 +01:00
Irit Katriel
68e72cf3a8 gh-100239: fix bug in comparison (#132093) 2025-04-04 18:09:49 +01:00
Bénédikt Tran
0a97427ee5 gh-99108: Implement HACL* HMAC (#130157)
A new extension module, `_hmac`, now exposes the HACL* HMAC (formally verified) implementation.

The HACL* implementation is used as a fallback implementation when the OpenSSL implementation of HMAC
is not available or disabled. For now, only named hash algorithms are recognized and SIMD support provided
by HACL* for the BLAKE2 hash functions is not yet used.
2025-04-04 19:04:00 +02:00
Mark Shannon
7099c75550 GH-131498: Cases generator: manage stacks automatically (GH-132074) 2025-04-04 17:59:36 +01:00
Irit Katriel
df59226997 gh-100239: more refined specialisation stats for BINARY_OP/SUBSCR (#132068) 2025-04-04 15:33:31 +01:00
Vincent Fazio
72123063dd gh-130115: fix thread identifiers for 32-bit musl (#130391)
CPython's pthread-based thread identifier relies on pthread_t being able
to be represented as an unsigned integer type.

This is true in most Linux libc implementations where it's defined as an
unsigned long, however musl typedefs it as a struct *.

If the pointer has the high bit set and is cast to PyThread_ident_t, the
resultant value can be sign-extended [0]. This can cause issues when
comparing against threading._MainThread's identifier. The main thread's
identifier value is retrieved via _get_main_thread_ident which is backed
by an unsigned long which truncates sign extended bits.

  >>> hex(threading.main_thread().ident)
  '0xb6f33f3c'
  >>> hex(threading.current_thread().ident)
  '0xffffffffb6f33f3c'

Work around this by conditionally compiling in some code for non-glibc
based Linux platforms that are at risk of sign-extension to return a
PyLong based on the main thread's unsigned long thread identifier if the
current thread is the main thread.

[0]: https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Arrays-and-pointers-implementation.html

---------

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
2025-04-04 16:31:37 +02:00
Tomasz Pytel
891c61c1fa gh-128632: fix segfault on nested __classdict__ type param (#128744) 2025-04-04 06:23:35 -07:00
Victor Stinner
37d47d4965 gh-125434: Display thread name in faulthandler (#132016) 2025-04-04 12:24:41 +00:00