Commit graph

130238 commits

Author SHA1 Message Date
Donghee Na
d1b541b047
gh-141510: Optimize {frozen}dict.fromkeys for frozendict (gh-144915) 2026-02-17 21:46:20 +00:00
Stan Ulbrych
fa73fd473f
gh-141510: Update test_xpickle for frozendict (#144927) 2026-02-17 21:26:29 +01:00
Victor Stinner
d1505b543a
gh-141510: Change repr(frozendict) for empty dict (#144921)
repr(frozendict()) returns "frozendict()" instead of
"frozendict({})".
2026-02-17 18:04:17 +00:00
Victor Stinner
8e211b1ca9
gh-141510: Optimize hash(frozendict) (#144919)
hash(frozendict) no longer creates a temporary items view and a
temporary frozenset object.

Copy frozenset_hash() code to frozendict_hash().
2026-02-17 18:39:33 +01:00
Sam Gross
6577d870b0
gh-144438: Fix false sharing between QSBR and tlbc_index (gh-144554)
Align the QSBR thread state array to a 64-byte cache line boundary
and add padding at the end of _PyThreadStateImpl. Depending on heap
layout, the QSBR array could end up sharing a cache line with a
thread's tlbc_index, causing QSBR quiescent state updates to contend
with reads of tlbc_index in RESUME_CHECK. This is sensitive to
earlier allocations during interpreter init and can appear or
disappear with seemingly unrelated changes.

Either change alone is sufficient to fix the specific issue, but both
are worthwhile to avoid similar problems in the future.
2026-02-17 11:12:25 -05:00
Donghee Na
1bd8cf9ed2
gh-141510: Remove unncessary lock holding for frozendict repr (gh-144920) 2026-02-17 14:52:50 +00:00
Donghee Na
fc05e5e3d7
gh-141510: Update mp_length of frozendict to use non atomic operation (gh-144913) 2026-02-17 13:39:56 +00:00
Hugo van Kemenade
6ef2578f20
Enable CPU tests on default ARM build (#144743) 2026-02-17 12:49:31 +02:00
Victor Stinner
696cdfc0a2
gh-141510, PEP 814: Add built-in frozendict type (#144757)
Add TYPE_FROZENDICT to the marshal module.

Add C API functions:

* PyAnyDict_Check()
* PyAnyDict_CheckExact()
* PyFrozenDict_Check()
* PyFrozenDict_CheckExact()
* PyFrozenDict_New()

Add PyFrozenDict_Type C type.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Adam Johnson <me@adamj.eu>
Co-authored-by: Benedikt Johannes <benedikt.johannes.hofer@gmail.com>
2026-02-17 10:54:41 +01:00
Victor Stinner
63531a3867
gh-143637: Fix test_socket.test_sendmsg_reentrant_ancillary_mutation() on Solaris (#144890)
Use socket.SCM_RIGHTS operation.
2026-02-17 10:49:30 +01:00
Mauricio Villegas
2f7634c029
gh-144782: Make sure that ArgumentParser instances are pickleable (#144783)
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2026-02-16 18:28:21 -08:00
Pablo Galindo Salgado
18c04f2e2a
gh-142349: Fix ast.unparse for lazy import statements (#144893)
The unparser was not handling the `is_lazy` attribute on Import and
ImportFrom AST nodes, causing lazy imports to be unparsed as regular
imports. This broke the round-trip (parse → unparse → reparse) for
any file containing `lazy import` statements.
2026-02-16 22:57:49 +00:00
Jason Yalim, PhD
185a6e942a
gh-140715: Add %D format code support to strptime() (GH-144819)
* %D support for strptime, including test and Doc update
* additional %D test
* change documentation example date for %D so it is more legible to non-US readers
* change testing date for %D so it is more legible to non-US readers
* mv News blurb to Library, consistent with previous %F change
* change invalid format code from %D to C-standard unused %!
* Fix erroneous and misleading example Doc to %y from %Y, use correct C99+ definition for C99 %D; update additional tests

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-02-16 14:20:37 -08:00
Pablo Galindo Salgado
1797508ead
gh-144878: Gate PEP 810 builtins in xpickle compat tests (#144889) 2026-02-16 21:48:08 +00:00
sblondon
837166f099
bpo-32234: Allow mailbox instances as context managers (GH-4770)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: R. David Murray <rdmurray@bitdance.com>
2026-02-16 14:14:26 +01:00
Serhiy Storchaka
8b7b5a9946
gh-80667: Fix Tangut ideographs names in unicodedata (GH-144789)
Co-authored-by: Pierre Le Marre <dev@wismill.eu>
2026-02-16 13:31:18 +02:00
Zachary Ware
ebe02e4f39
gh-144551: Update iOS builds to use OpenSSL 3.0.19 (GH-144865) 2026-02-15 23:02:23 -06:00
Zachary Ware
87c7f193b8
gh-144551: Update Android builds to use OpenSSL 3.0.19 (GH-144864) 2026-02-15 23:02:07 -06:00
Ramin Farajpour Cami
c91638ca06
gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-144843)
In newPySSLSocket(), when SSL_new() returns NULL, Py_DECREF(self)
was called before _setSSLError(get_state_ctx(self), ...), causing
a use-after-free. Additionally, get_state_ctx() was called with
self (PySSLSocket*) instead of sslctx (PySSLContext*), which is
a type confusion bug.

Fix by calling _setSSLError() before Py_DECREF() and using
sslctx instead of self for get_state_ctx().
2026-02-15 18:43:07 -08:00
Gregory P. Smith
300de1e98a
gh-86519: Add prefixmatch APIs to the re module (GH-31137)
Adds `prefixmatch` APIs to the re module as an alternate name for our long existing `match` APIs to help alleviate a common Python confusion for those coming from other languages regular expression libraries.

These alleviate common confusion around what "match" means as Python is different than other popular languages regex libraries in our use of the term as an API name.  The original `match` names are **NOT being deprecated**.  Source tooling like linters, IDEs, and LLMs could suggest using `prefixmatch` instead of match to improve code health and reduce cognitive burden of understanding the intent of code when configured for a modern minimum Python version.

See the documentation changes for a better description.

Discussions took place in the PR, in the issue, and finally at https://discuss.python.org/t/add-re-prefixmatch-deprecate-re-match/105927

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:43:39 -08:00
Pablo Galindo Salgado
5fe139cc39
gh-144727: Add test for circular lazy import crash (#144727) (#144838)
Add a regression test ensuring that circular lazy imports raise a proper
error (ImportCycleError) instead of crashing with a segfault. The crash
was fixed in gh-144733 but no test was added at the time.
2026-02-15 18:36:47 +00:00
Pablo Galindo Salgado
23c488d619
Format CODEOWNERS file (#144842) 2026-02-15 16:11:16 +00:00
Pablo Galindo Salgado
5a6615ff92
gh-142349: Add CODEOWNERS for lazy imports (#144840) 2026-02-15 16:07:03 +00:00
Kumar Aditya
50c479e613
add whatsnew entry for PyUnstable_SetImmortal and PyDatetime_IMPORT (#144830) 2026-02-15 20:21:54 +05:30
Ramin Farajpour Cami
e6110efd03
gh-144759: Fix undefined behavior from NULL pointer arithmetic in lexer (#144788)
Guard against NULL pointer arithmetic in `_PyLexer_remember_fstring_buffers`
and `_PyLexer_restore_fstring_buffers`. When `start` or `multi_line_start`
are NULL (uninitialized in tok_mode_stack[0]), performing `NULL - tok->buf`
is undefined behavior. Add explicit NULL checks to store -1 as sentinel
and restore NULL accordingly.

Add test_lexer_buffer_realloc_with_null_start to test_repl.py that
exercises the code path where the lexer buffer is reallocated while
tok_mode_stack[0] has NULL start/multi_line_start pointers. This
triggers _PyLexer_remember_fstring_buffers and verifies the NULL
checks prevent undefined behavior.
2026-02-15 14:39:57 +00:00
Benedikt Johannes
645f5c4a73
gh-144822: remove redundant decref in codegen.c (#144823) 2026-02-14 19:20:33 +00:00
Chris Eibl
caac966b00
fix warnings in jit builds (GH-144817) 2026-02-14 17:39:10 +00:00
Chris Eibl
14cbd0e6af
remove unused _PyFunction_LookupByVersion (GH-144814) 2026-02-14 14:09:01 +00:00
Yilei
5922149a50
gh-144766: Fix a crash in fork child process when perf support is enabled. (#144795) 2026-02-14 11:41:28 +00:00
Marc Mueller
75d4839fa9
gh-138912: Improve MATCH_CLASS opcode performance (GH-138915)
Only check for duplicates if there is at least one positional pattern.
With a test case for duplicate keyword attributes.
2026-02-13 21:06:15 -08:00
Zachary Ware
fdbc135f9c
gh-144551: Update various CI jobs to OpenSSL 3.5 (GH-144808)
Also includes a fix to the address sanitizer build to build the `_ssl`
module against the expected OpenSSL build.
2026-02-13 23:02:11 +00:00
Zachary Ware
7359bb8dac
gh-144551: Update OpenSSL version references in Mac/BuildScript/ (GH-144810) 2026-02-13 16:50:15 -06:00
Zachary Ware
543f56fe8d
gh-144551: Update Windows builds to use OpenSSL 3.5.5 (GH-144796) 2026-02-13 15:43:05 -06:00
Rafael Weingartner-Ortner
629a363ddd
gh-136672: Docs: Move parts of Enum HOWTO to API Docs (GH-139176)
To avoid duplicate content in the Enum HOWTO and
API documentation which is not automatically synced,
the section about supported __dunder__ and _sunder
names is moved from HOWTO to API docs.

See also https://github.com/python/cpython/pull/136791
2026-02-13 11:51:56 -08:00
Zachary Ware
b933ef9261
gh-144551: Update CI to use latest OpenSSL versions (GH-144794)
Also update _ssl_data_36.h to include an added symbol from 3.6.1.
2026-02-13 13:06:07 -06:00
Zachary Ware
928602c0ac
gh-144551: Update Windows builds to use OpenSSL 3.0.19 (GH-144793) 2026-02-13 18:48:52 +00:00
Colin McAllister
d625f7da33
gh-144787: [tests] Allow TLS v1.2 to be minimum version (GH-144790)
Allow TLS v1.2 to be minimum version

Updates test_min_max_version to allow TLS v1.2 to be minimum version if
TLS 1.0 and 1.1 are disabled in OpenSSL.
2026-02-13 17:17:53 +00:00
Priyanshu Singh
82b92e3cd1
gh-143637: Fix re-entrant mutation of ancillary data in socket.sendmsg() (#143892)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-02-13 16:35:08 +01:00
Robsdedude
945bf8ce1b
gh-144706: Warn against using synchronization primitives within signal handlers (GH-144736) 2026-02-12 18:15:23 -05:00
Seth Michael Larson
66da7bf6fe
gh-143916: Allow HTAB in wsgiref header values
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-02-12 20:40:21 +00:00
Victor Stinner
b488f338cf
gh-135906: Test more internal headers in test_cext/test_cppext (#144751) 2026-02-12 19:40:42 +01:00
James
e66f4a5a9c
gh-80667: Fix case-sensitivity of some Unicode literal escapes (GH-107281)
Lookup for CJK ideograms and Hangul syllables is now case-insensitive,
as is the case for other character names.
2026-02-12 18:50:40 +02:00
Victor Stinner
9e5e1f9988
gh-121617: Include <string.h> for Py_CLEAR() macro (#144666)
Python.h now also includes <string.h> in the limited C API version 3.11
and newer to fix the Py_CLEAR() macro which uses memcpy().

Add a Py_CLEAR() test in test_cext.

Modify also _Py_TYPEOF to use C23 typeof() if available.
2026-02-12 17:03:55 +01:00
Victor Stinner
eb6ebdbc95
gh-138744: Upgrade Windows to 2025 in GitHub Actions (#144682)
Replace windows-2022 with windows-2025.
2026-02-12 16:19:50 +01:00
Bartosz Sławecki
b6b72e7663
gh-144285: Improve AttributeError attribute suggestions (#144299) 2026-02-12 14:12:49 +00:00
Pablo Galindo Salgado
072cd7c336
gh-142349: Fix refcount corruption in lazy import specialization (#144733)
Remove spurious Py_DECREF on borrowed ref in LOAD_GLOBAL specialization

_PyDict_LookupIndexAndValue() returns a borrowed reference via
_Py_dict_lookup(), but specialize_load_global_lock_held() called
Py_DECREF(value) on it when bailing out for lazy imports. Each time
the adaptive counter fired while a lazy import was still in globals,
this stole one reference from the dict's object. With 8+ threads
racing through LOAD_GLOBAL during concurrent lazy import resolution,
enough triggers accumulated to drive the refcount to zero while the
dict and other threads still referenced the object, causing
use-after-free.
2026-02-12 11:45:28 +00:00
Stan Ulbrych
2e3e76e5cd
gh-57095: Add note about input splitting in datetime.*.strptime (GH-131049)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-02-12 11:35:42 +01:00
Stan Ulbrych
51a408ed77
Add missing step to Modules/expat/refresh.sh instructions (GH-144719) 2026-02-12 09:55:26 +01:00
Pablo Galindo Salgado
7854597d88
gh-142349: Fix build errors from PEP 810 (#144726) 2026-02-12 08:18:36 +00:00
Adorilson Bezerra
f912c835b9
gh-106318: Fix incorrectly rendered code block in str.isalnum() docs (GH-144718) 2026-02-12 08:40:17 +01:00