Commit graph

15724 commits

Author SHA1 Message Date
Pablo Galindo Salgado
21fb9dc71d
gh-146527: Heap-allocate gc_stats to avoid bloating PyInterpreterState (#148057)
The gc_stats struct contains ring buffers of gc_generation_stats
entries (11 young + 3×2 old on default builds). Embedding it inline
in _gc_runtime_state, which is itself inline in PyInterpreterState,
pushed fields like _gil.locked and threads.head to offsets beyond
what out-of-process profilers and debuggers can reasonably read in
a single buffer (e.g. offset 9384 for _gil.locked vs an 8 KiB read
buffer).

Heap-allocate generation_stats via PyMem_RawCalloc in _PyGC_Init and
free it in _PyGC_Fini. This shrinks PyInterpreterState by ~1.6 KiB
and keeps the GIL, thread-list, and other frequently-inspected fields
at stable, low offsets.
2026-04-04 18:42:30 +01:00
Stan Ulbrych
fe9befc1ca
gh-145883: Fix two heap-buffer-overflows in _zoneinfo (#145885) 2026-04-04 13:29:17 +01:00
Kumar Aditya
e7bf8eac0f
gh-131798: split recursion check to _CHECK_RECURSION_LIMIT and combine checks (GH-148070) 2026-04-04 17:23:03 +08:00
Serhiy Storchaka
113038f940
gh-148016: Improve "Leading padding not allowed" error in Base32 and Base64 decoders (GH-148017)
It is now raised instead of "Excess padding not allowed" if all characters
preceding "=" were ignored.
2026-04-04 08:37:14 +00:00
Serhiy Storchaka
985216ced3
gh-148029: Fix error message for invalid number of Base32 characters (GH-148030)
Do not count ignored non-alphabet characters.
2026-04-04 11:07:19 +03:00
Kumar Aditya
7e275d4965
gh-131798: JIT inline function addresses of builtin methods (#146906) 2026-04-04 09:12:13 +05:30
Sergey Miryanov
c1b20a6d96
GH-145247: Use _PyTuple_FromPair in Modules (part 2) (#148003)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-04-02 23:24:03 +02:00
Sergey Miryanov
0c100664bc
GH-145247: Use _PyTuple_FromPair in Modules (part 1) (#148000) 2026-04-02 23:20:13 +02:00
Ma Yukun
fc7a188fe7
gh-146613: Fix re-entrant use-after-free in itertools._grouper (#147962) 2026-04-02 19:04:58 +05:30
Victor Stinner
c1a4112c22
gh-147988: Initialize digits in long_alloc() in debug mode (#147989)
When Python is built in debug mode:

* long_alloc() now initializes digits with a pattern to detect usage of
  uninitialized digits.
* _PyLong_CompactValue() now makes sure that the digit is zero when the
  sign is zero.
* PyLongWriter_Finish() now raises SystemError if it detects uninitialized
  digits

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-04-02 11:55:34 +00:00
Petr Viktorin
a86963b3e2
gh-146636: Py_mod_abi mandatory for modules created from slots array (GH-146855) 2026-04-02 13:54:21 +02:00
Serhiy Storchaka
473d2a35ce
gh-147944: Increase range of bytes_per_sep (GH-147946)
Accepted range for the bytes_per_sep argument of bytes.hex(),
bytearray.hex(), memoryview.hex(), and binascii.b2a_hex()
is now increased, so passing sys.maxsize and -sys.maxsize is now
valid.
2026-04-01 08:33:30 +00:00
Serhiy Storchaka
42825e6387
gh-146431: Add the wrapcol and ignorechars parameters for more Base XX codec (GH-146434)
Add the wrapcol parameter to base64 functions b16encode(), b32encode(),
b32hexencode(), b85encode() and z85encode(), and binascii functions
b2a_base32() and b2a_base85().

Add the ignorechars parameter to base64 functions b16decode(), b32decode(),
b32hexdecode(), b85decode() and z85decode(), and binascii functions
a2b_hex(), unhexlify(), a2b_base32() and a2b_base85().
2026-04-01 10:48:50 +03:00
Sergey B Kirpichev
db5936c5b8
gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (#145901)
The long_from_string_base() might return a small integer, when the
_pylong.py is used to do conversion.  Hence, we must be careful here to
not smash it "small int" bit by using the _PyLong_FlipSign().

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-31 13:17:49 +00:00
sunmy2019
b7055533ab
gh-146615: Fix format specifiers in test cextensions (GH-146618) 2026-03-31 10:58:27 +03:00
sunmy2019
1c396e1821
gh-146615: Fix format specifiers in extension modules (GH-146617) 2026-03-31 10:57:37 +03:00
Sergey B Kirpichev
e79fd60339
gh-146238: Support half-floats in the array module (#146242)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-30 19:48:34 +00:00
cui
4d0e8ee649
gh-146579: _zstd: Fix decompression options dict error message (#146577)
The TypeError in _zstd_set_d_parameters incorrectly referred to
compression options; say decompression options instead.
2026-03-29 12:58:12 -07:00
Stan Ulbrych
e39d84a37d
gh-146083: Upgrade bundled Expat to 2.7.5 (#146085) 2026-03-29 19:05:14 +02:00
Bénédikt Tran
24db78c532
gh-146080: fix a crash in SNI callbacks when the SSL object is gone (#146573) 2026-03-29 14:27:22 +02:00
Bénédikt Tran
aa6680775d
gh-146090: fix memory management of internal sqlite3 callback contexts (#146569) 2026-03-29 14:21:37 +02:00
Serhiy Storchaka
6932c3ee6a
gh-145876: Do not mask KeyErrors raised during dictionary unpacking in call (GH-146472)
KeyErrors raised in keys() or __getitem__() during dictionary unpacking
in call (func(**mymapping)) are no longer masked by TypeError.
2026-03-29 11:58:52 +03:00
Sergey Miryanov
5bf3a31bc2
GH-146527: Add more data to GC statistics and add it to PyDebugOffsets (#146532) 2026-03-28 18:52:10 +00:00
Neko Asakura
a492d9ff74
gh-145866: Convert LIST_EXTEND to leave its inputs on the stack to be cleaned up by _POP_TOP be cleaned up by _POP_TOP (GH-146383) 2026-03-28 01:04:17 +08:00
Pieter Eendebak
9214e3f33e
gh-123471: Make itertools.zip_longest safe in the FT build (#146033) 2026-03-27 19:31:49 +05:30
Victor Stinner
d4153a9f76
gh-146480: Override the exception in _PyErr_SetKeyError() (#146486)
If _PyErr_SetKeyError() is called with an exception set, it now
replaces the current exception with KeyError (as expected), instead
of setting a SystemError or failing with a fatal error (in debug
mode).
2026-03-27 11:20:19 +00:00
Joao S. O. Bueno
d0061d50b0
gh-146440: Add array_hook parameter to JSON decoders (#146441)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-27 11:10:48 +00:00
Serhiy Storchaka
17070f41d4
gh-144837: Improve documentation for more collection methods (GH-144841)
Use uniform standard signature syntax in the tutorial and in
the array and collections modules documentation.
2026-03-26 21:29:23 +02:00
Victor Stinner
5c0dcb3e0d
gh-146059: Call fast_save_leave() in pickle save_frozenset() (#146173)
Add more pickle tests: test also nested structures.
2026-03-26 17:35:27 +01:00
Sergey B Kirpichev
0e3b3b895c
gh-146151: Add support for complex arrays in the array module (#146237)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-26 15:45:20 +01:00
Sergey B Kirpichev
c68a19448a
gh-146151: memoryview supports 'F' and 'D' format types (complex) (#146241)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-26 15:26:34 +01:00
Kumar Aditya
bfdaa3c565
gh-131798: JIT: split call method and call builtin opcodes into smaller uops (#146463) 2026-03-26 14:20:57 +00:00
Serhiy Storchaka
0e543055b0
gh-145876: Do not mask AttributeErrors raised during dictionary unpacking (GH-145906)
AttributeErrors raised in keys() or __getitem__() during
dictionary unpacking ({**mymapping} or func(**mymapping)) are
no longer masked by TypeError.
2026-03-26 13:48:57 +00:00
Sacul
1516c26399
gh-145866: Convert DICT_UPDATE to leave its inputs on the stack to be cleaned up by _POP_TOP (GH-146190) 2026-03-26 19:38:44 +08:00
Victor Stinner
8de70b31c5
gh-145633: Fix struct.pack('f') on s390x (#146422)
Use PyFloat_Pack4() to raise OverflowError.
Add more tests on packing/unpacking floats.

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-03-26 11:12:49 +00:00
Kevin Huai
f5364ae750
gh-145866: Convert _CALL_INTRINSIC_2 to leave its inputs on the stack to be cleaned up by _POP_TOP (GH-146262) 2026-03-26 17:41:07 +08:00
Victor Stinner
3364e7e62f
gh-146207: Add support for OpenSSL 4.0.0 alpha1 (#146217)
OpenSSL 4.0.0 alpha1 removed these functions:

* SSLv3_method()
* TLSv1_method()
* TLSv1_1_method()
* TLSv1_2_method()

Other changes:

* Update test_openssl_version().
* Update multissltests.py for OpenSSL 4.
* Add const qualifier to fix compiler warnings.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-03-25 07:44:47 +01:00
Sergey B Kirpichev
f2fcc49467
gh-145633: Remove remnants of the "unknown_format" (floats) in the struct module (#146189) 2026-03-25 07:23:44 +01:00
Sergey B Kirpichev
f4d1be46b4
gh-145633: Drop runtime checks for floatting-point formats in the array module (#146162) 2026-03-25 07:06:38 +01:00
Karolina Surma
1887a95f51
gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770)
Rename from _Py_INTERNAL_ABI_SLOT to _Py_ABI_SLOT
and define the macro using _PyABIInfo_DEFAULT.

Use the ABI slot in stdlib extension modules to enable running
a check of ABI version compatibility.

_tkinter, _tracemalloc and readline don't use the slots, hence they need
explicit handling.

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-24 17:47:55 +00:00
Neko Asakura
6d73bc2267
gh-145866: Convert DICT_MERGE to leave its inputs on the stack to be cleaned up by _POP_TOP (GH-146329) 2026-03-24 18:31:41 +08:00
Petr Viktorin
91cd2e5806
gh-146175: Soft-deprecate outdated macros; convert internal usage (GH-146178)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-23 12:42:09 +01:00
Victor Stinner
90f9991abb
gh-146056: Rework ref counting in treebuilder_handle_end() (#146167)
Use more regular code to handle reference counting in
treebuilder_handle_end().

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-03-23 12:17:54 +01:00
Serhiy Storchaka
4561f6418a
gh-145264: Do not ignore excess Base64 data after the first padded quad (GH-145267)
Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc)
no longer ignores excess data after the first padded quad in non-strict
(default) mode.  Instead, in conformance with RFC 4648, it ignores the
pad character, "=", if it is present before the end of the encoded data.
2026-03-22 23:12:58 +02:00
Pablo Galindo Salgado
ae6adc9079
gh-146308: Fix error handling issues in _remote_debugging module (#146309) 2026-03-22 21:12:02 +00:00
kangtastic
b4e5bc2164
gh-146192: Add base32 support to binascii (GH-146193)
Add base32 encoder and decoder functions implemented in
C to the binascii module and use them to greatly improve the
performance and reduce the memory usage of the existing
base32 codec functions in the base64 module.
2026-03-22 23:10:28 +02:00
flow
a17301ab3d
gh-135953: Properly obtain main thread identifier in Gecko Collector (#146045) 2026-03-22 18:53:00 +00:00
AN Long
c30fae4bea
gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) 2026-03-22 13:29:34 +02:00
Mark Shannon
879c85f6e4
GH-145667: Merge GET_ITER and GET_YIELD_FROM_ITER (GH-146120)
* Merge GET_ITER and GET_YIELD_FROM_ITER. Modify SEND to make it a bit more like FOR_ITER
2026-03-21 10:48:13 +00:00
Victor Stinner
b36b87bcbb
gh-145980: Fix copy/paste mistake in binascii.c (#146230) 2026-03-20 18:12:10 +00:00