Commit Graph
10597 Commits
Author SHA1 Message Date
Kumar Aditya d4f52c445b gh-157526: Call __instancecheck__ and __subclasscheck__ without creating a bound method (#157670) 2026-09-22 11:16:30 +05:30
Peter Gessler f8b0e26a6a gh-150737: Optimize bytecode for empty unpack cases such as `{*()}`. (#150812) 2026-09-20 21:53:10 -07:00
ノウラ | Flare 9193375382 gh-157549: Use sysconf() for the page size in remote_debug.h (#157800)
getpagesize() is not an ISO C or POSIX function. Darwin hides the prototype under -std=c11, so the _remote_debugging build fails with -Werror=implicit-function-declaration. That is the failure in the reported x86_64-apple-darwin → arm64-apple-darwin cross build.

Call sysconf(_SC_PAGESIZE) instead, which is already how resource.getpagesize() works. Fall back to 4096 if sysconf() fails.

--without-remote-debug is unchanged. That flag only disables the target-side attach protocol (Py_REMOTE_DEBUG); it does not exclude the _remote_debugging client module.
2026-09-19 16:11:49 +00:00
Serhiy Storchaka 6b5d4143f3 gh-113318: Better implementation of @getter and @setter in Argument Clinic (GH-156066)
The value of a @setter is now a parameter, which can use a converter,
and a @getter can define a return converter.  Declaring the value is
optional.

The accessors of an attribute are now collected in a Property, so the
entry of PyGetSetDef is identified by the Python name instead of the C
basename, and is composed without the help of the preprocessor unless
some accessor is compiled conditionally.
2026-09-19 18:48:39 +03:00
Shamil 6dad8b88cc gh-156114: Fix crash in perf trampoline with unencodable code names (#156300) 2026-09-18 17:04:21 -04:00
Serhiy StorchakaandClaude Opus 5 76f22f9cf2 gh-156942: Raise the exception where the marshalling error is detected (GH-156944)
Previously the marshal writer recorded an error code and converted it into
an exception at the end, replacing the exception which was already raised
with ValueError("unmarshallable object").  Error messages now name the type
of the unsupported object and the required version.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 17:14:25 +00:00
Serhiy Storchaka 92db1519aa gh-86427: Determine the stdio encoding for every standard stream on Windows (GH-155416)
It was the ANSI code page instead of the encoding of the device the stream
is connected to, as in 3.7.

The stdio encoding is now left undefined in this mode and determined for
every standard stream.
2026-09-18 20:03:25 +03:00
Victor Stinner 86c93a5b84 gh-155742: Use PyBytesWriter in _Py_strhex_impl() (#157734)
Replace soft deprecated PyBytes_FromStringAndSize() with
PyBytesWriter.

Replace also PyBytes_FromStringAndSize(NULL, 0) with
Py_GetConstant(Py_CONSTANT_EMPTY_BYTES) in other functions.

Replace also PyBytes_FromStringAndSize(NULL, 0) with
PyBytes_FromStringAndSize("", 0) in _Py_GetConstant_Init().
2026-09-18 14:09:09 +02:00
Victor StinnerandNathan Goldbaum d1878ccb44 gh-157415: Fix data race in pthread wrapper (#157430)
Use free() instead of PyMem_RawFree() in pythread_wrapper() to avoid
a data race if another thread calls PyMem_SetAllocator() in parallel.

Reenable @nomemtest tests on TSAN.

Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
2026-09-17 16:34:50 +02:00
Victor StinnerandPetr Viktorin 8bcbcf8cfc gh-155742: Check singletons consistency at Python exit (#157572)
In debug mode at Python exit, check if immutable singleton objects
have been modified by mistake to detect bugs in C extensions.

Add tests corrupting bytes, str, bool and int singleton objects.

Add pycore_global_objects_fini.h internal header file.
pycore_global_objects_fini_generated.h is now fully generated by the
script.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-09-17 16:03:45 +02:00
Kumar Aditya 0a6c1ed341 gh-157361: Implement anext() in Python instead of C (#157362) 2026-09-16 18:58:59 +05:30
Bartosz Sławecki 1bfcc3cc87 gh-156909: Fix AST.__repr__ call getting the _fields attribute (GH-157490) 2026-09-15 08:26:26 +02:00
Victor Stinner ab5b14789d gh-155742: Use PyBytesWriter in Python/assemble.c (#157349)
Replace soft deprecated _PyBytes_Resize() with PyBytesWriter.
2026-09-14 23:52:44 +02:00
Bartosz Sławecki b62380fdb8 gh-156021: Don't include ... for empty AST node representations (GH-156022) 2026-09-14 14:06:22 +02:00
Victor Stinner 658612ae77 gh-128509: Use bytes singletons in marshal (#157398)
Replace soft deprecated PyBytes_FromStringAndSize(NULL, n) with
PyBytes_FromStringAndSize(str, n) so marshal can get bytes singleton.
2026-09-13 12:11:07 +00:00
Pablo Galindo Salgado 7bfa97f4dc gh-153569: hide tokenizer state behind token and source operations (#156654)
Make pegen and _tokenize consume tokenizer operations instead of accessing the tokenizer layout. Return token kind, span, location, and raw-string context together, so parser actions use the context of the cached token.

Represent persistent scanner positions as offsets and remove pointer save/restore bookkeeping when input storage grows.
2026-09-12 14:30:00 +01:00
Hai Zhu 4c9f2675ba gh-157247: Block perf trampoline activation when the main interpreter's JIT is enabled (#157258) 2026-09-11 19:07:26 +05:30
thexai 5172fa4cd9 gh-152433: Windows: make `dynload_win.c` UWP compatible (#152797) 2026-09-11 15:35:34 +02:00
thexai 1b1b9b3021 gh-152433: Windows: allow build `ceval.c` for UWP (#152689) 2026-09-11 12:16:27 +02:00
Clément PéronandClaude Fable 5.1 d0b2e0735f gh-156780: Emscripten: drop the trampoline's dependence on exports (#157238)
The trampoline exports _PyRuntime's address itself and reuses a
placeholder's table slot, so libpython no longer needs
-sEXPORTED_FUNCTIONS=__PyRuntime or a growable function table.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-11 09:22:36 +08:00
Jonathan J. Helmus 4849a01020 gh-153400: Support os.getrandom() on old glibc versions (#155762)
Use the libc-provided SYS_getrandom syscall number when available,
falling back to the kernel-provided __NR_getrandom when necessary.
2026-09-10 22:58:27 +02:00
Pablo Galindo Salgado 2ddc218b20 gh-153569: centralize formatted-string state and source spans (#156484)
Formatted-string expressions and comments can outlive the buffer window where
scanning began. Pointer boundaries require buffer relocation to repair tokenizer
state. Record logical source ranges instead. Retain the active input window while a
formatted string is open, give each mode ownership of its comment spans, and
materialize text through shared span views.
2026-09-09 00:15:01 +01:00
Clément PéronandClaude Opus 5 0b3b154060 gh-156780: Emscripten: add missing EM_JS_DEPS (#156798)
Explicitly declares some Javascript dependencies to support static builds.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 15:26:48 +08:00
Pablo Galindo Salgado 09117bc317 gh-153569: return token spans and unify decoded source storage (#156482)
Represent token boundaries as logical source offsets with explicit start
and end locations, and adapt pegen and _tokenize to consume them.

Use SourceText to own decoded input across all reader modes. Streaming
readers discard consumed windows while preserving logical offsets and
reusing the allocation. Prepared and interactive input retain their source.

Force source relocation on growth in debug builds and add coverage for
formatted-string growth, interactive input, storage reuse, and offset
limits. Scanner positions remain pointers, rebased when storage moves.
2026-09-06 21:15:44 +01:00
Irit Katriel 14a93f4d91 gh-156091: Fix crash compiling deeply nested inlined comprehensions (#156957) 2026-09-05 16:01:05 +00:00
Irit Katriel e56f86fb6c gh-143493: fix cleanup on errors in codegen_comprehension (#156374) 2026-09-04 17:15:44 +00:00
Serhiy StorchakaandClaude Opus 5 aaae15c35b gh-155907: Fix error handling in the marshal C API (GH-155909)
Functions reading marshalled data from a FILE* now raise OSError for I/O
errors and KeyboardInterrupt for interrupted reading, instead of EOFError.

PyMarshal_WriteObjectToFile() and PyMarshal_WriteLongToFile() now detect
I/O errors and interrupted writing instead of ignoring them.
PyMarshal_WriteObjectToFile() now also sets the error indicator if the
value cannot be marshalled.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 16:44:57 +03:00
cui fliter e13ecaeca2 gh-155141: Improve stack-use estimation for keyword calls (#155785) 2026-09-03 13:06:35 +00:00
Kumar Aditya db92901405 gh-144446: Fix thread safety of gi_frame, cr_frame and ag_frame in free-threading (#156037) 2026-09-02 23:26:04 +05:30
Victor Stinner 0f34848214 gh-155742: Use PyBytesWriter in codecs (#155750)
Use PyBytesWriter in _PyCodec_SurrogateEscapeUnicodeEncodeError().

Replace soft deprecated PyBytes_FromStringAndSize() with
PyBytesWriter.
2026-09-01 15:29:26 +02:00
Serhiy StorchakaandClaude Opus 5 1620e0f1b5 gh-64862: Add the stop_exception parameter in iter() and aiter() (GH-156298)
The iteration stops when the callable raises the specified exception (an
exception class or a tuple of exception classes).  It is keyword-only and
can be used without the stop value.  The second parameter of iter() is now
named stop_value and can be passed as a keyword argument.

aiter() now accepts the same parameters, which it never had before: the
callable is called and its result is awaited for every __anext__().

If the callable raises StopIteration (StopAsyncIteration in aiter()) which
does not match stop_exception, it is replaced with RuntimeError, as PEP 479
and PEP 525 do for generators.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 15:55:32 +03:00
Stan Ulbrych d7f9c6400f gh-156689: Fix out-of-bounds read in PyAst_CheckMode() for mode='func_type' (#156697) 2026-08-31 12:49:03 +01:00
Kumar Aditya 6b1b90f7c4 gh-155725: Remove PyGILState_Ensure usage from tracemalloc (#156409) 2026-08-30 13:04:55 +05:30
Irit Katriel 41b3f0af26 gh-156466: fix cleanup on error after Enter in codegen_enter_scope (#156467) 2026-08-29 22:40:37 +01:00
Serhiy Storchaka 0bb312a4ea gh-86427: Use the console code page for the stdio encoding on Windows (GH-155415)
In the legacy Windows stdio mode PyConfig.stdio_encoding is now initialized
with the console output code page instead of the ANSI code page.

Only one encoding can be specified, so sys.stdin.encoding is still wrong if
the input code page differs from the output one.
2026-08-29 22:17:43 +03:00
Serhiy Storchaka b4aea41d1c gh-87587: Fix os.device_encoding() for any console on Windows (GH-155410)
It was hard coded to map file descriptors 0, 1 and 2 to the console code
page, but a console can be opened as any file descriptor, and other
character devices, like NUL, are not consoles.

The file handle is now queried.  The UTF-8 code page is also now reported
as "utf-8" instead of "cp65001".
2026-08-29 21:15:25 +03:00
e1d969ad95 gh-148653: Forbid marshalling recursive tuples (GH-155903)
Also fix a crash when unmarshalling a self-referencing tuple.

Co-authored-by: Michael Bommarito <michael.bommarito@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 19:01:09 +03:00
Irit Katriel d94c4ad1b6 gh-156466: fix cleanup on error in codegen_function_body (#156511) 2026-08-29 15:01:55 +01:00
Irit Katriel 8b082aa405 gh-156459: Fix cleanup on error in compiler_set_qualname (#156462) 2026-08-29 12:22:25 +00:00
Jelle Zijlstra f4874f381c gh-156466: Fix additional compiler scope cleanup errors (#156547) 2026-08-29 13:14:29 +01:00
Irit Katriel 683ef4082d gh-156466: fix cleanup on error in codegen_class_body (#156507) 2026-08-28 21:01:47 +00:00
Irit Katriel 932822cbc9 gh-156525: fix a few error path scope management bugs in symtable (#156526) 2026-08-28 19:10:37 +01:00
Pablo Galindo Salgado f5dbcbafae gh-153569: Unify tokenizer input readers (#156472) 2026-08-28 17:26:05 +02:00
Irit Katriel 8e0159bd23 gh-156466: fix cleanup on error in codegen_leave_annotations_scope (#156497) 2026-08-28 15:03:56 +01:00
Irit Katriel 0e29768493 gh-156466: fix cleanup on error in codegen_function_annotations (#156502) 2026-08-28 11:25:52 +01:00
Irit Katriel 24e5a55ccb gh-156466: fix cleanup on error in codegen_setup_annotations_scope (#156473) 2026-08-27 21:11:05 +01:00
Dino Viehland 9036982ed7 gh-156395: Report frozen objects on free-threaded GC build (#156396)
Report frozen objects on free-threaded GC build
2026-08-26 07:29:09 -07:00
Hood Chatham 05eac890c2 gh-156243: Indicate that emscripten_runtime depends on stringToNewUTF8 (#156335)
Add an explicit declaration an Emscripten dependency on the stringToNewUTF8
library function.
2026-08-26 07:50:13 +10:00
Steve Dower ee521e8ac1 gh-148750: Unfreeze encodings module to avoid import errors with zipped stdlib (GH-156183)
(Reverts fixes applied as part of gh-145278)
2026-08-24 20:19:30 +01:00
Kirill Podoprigora 3a5aa68588 gh-156126: Fix crash in -X importtime with unencodable module names (#156137) 2026-08-23 10:32:56 +03:00