Commit graph

56545 commits

Author SHA1 Message Date
Raymond Hettinger
7258dbc518
Use lazy imports in collections (gh-145054) 2026-02-21 08:14:53 -06:00
Stan Ulbrych
e1bd0cd37b
gh-145058: Add input validation to _PyImport_LazyImportModuleLevelObject (#145068) 2026-02-21 12:52:40 +00:00
Victor Stinner
2133e16bfe
gh-141510: Fix test_xpickle for Python 3.14 and older (#145069)
Skip tests on frozendict on Python 3.14 and older.
2026-02-21 13:05:35 +01:00
Bénédikt Tran
3a2a686cc4
gh-142516: fix reference leaks in ssl.SSLContext objects (#143685) 2026-02-21 12:31:16 +01:00
Victor Stinner
7b0bd9eb91
gh-141510, PEP 814: Add frozendict support to json (#144903) 2026-02-21 12:22:47 +01:00
Bénédikt Tran
347fc438cf
gh-143698: correctly check scheduler and setpgroup values for os.posix_spawn[p] (#143699)
Fix an issue where passing invalid arguments to `os.posix_spawn[p]` functions
raised a SystemError instead of a TypeError, and allow to explicitly use `None`
for `scheduler` and `setpgroup` as specified in the docs.
2026-02-21 11:20:42 +00:00
Victor Stinner
20b1535ca4
gh-141510, PEP 814: Add frozendict support to pickle (#144967)
Add frozendict.__getnewargs__() method.
2026-02-21 11:07:55 +01:00
Rafael Santos
273d5062ca
gh-145028: Fix blake2 tests in test_hashlib when it is missing due to build config (GH-145029)
specifically configure --without-builtin-hashlib-hashes means the otherwise guaranteed available blake2 family will not exist.  this allows the test suite to still pass.
2026-02-20 20:57:29 -08:00
Sam Gross
70da972f97
gh-144809: Make deque copy atomic in free-threaded build (gh-144966) 2026-02-20 14:31:58 -05:00
Alper
a56532771a
gh-144981: Make PyUnstable_Code_SetExtra/GetExtra thread-safe (#144980)
* Make PyUnstable_Code_SetExtra/GetExtra thread-safe
2026-02-20 10:52:18 -08:00
Anton Ryzhov
175ab31377
Update comments in _strptime module (GH-144979)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-02-20 08:56:56 +01:00
J Berg
4141f0a1ee
Correct MAX_N in Lib/zipfile ZipExtFile (GH-144973)
"<<" has lower precedence than "-".
2026-02-20 00:48:01 +02:00
Robsdedude
0f7cd5544a
gh-144156: Fix email header folding concatenating encoded words (#144692)
The fix for gh-92081 (gh-92281) was unfortunately flawed, and broke whitespace handling for encoded word patterns that had previously been working correctly but had no corresponding tests, unfortunately in a way that made the resulting headers not RFC compliant, in such a way that Yahoo started rejecting the resulting emails.  This fix was released in 3.14 alpha 1, 3.13 beta 2 and 3.12.5.   This PR fixes the original problem in a way that does not break anything, and in fact fixes a small pre-existing bug (a spurious whitespace after the ':' of the header label if the header value is immediately wrapped on to the next line).  (RDM)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: R. David Murray <rdmurray@bitdance.com>
2026-02-19 13:29:05 -05:00
Stan Ulbrych
930b3fd1df
compute-changes.py: Fix & test process_changed_files() (#144674)
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2026-02-19 18:49:34 +02:00
Filipe Laíns
f282f7aed9
GH-134872: add ModuleNotFoundError suggestions (#142512)
* gh-134872: Add traceback suggestions for ModuleNotFoundError

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Add news

Signed-off-by: Filipe Laíns <lains@riseup.net>

---------

Signed-off-by: Filipe Laíns <lains@riseup.net>
2026-02-19 16:10:58 +00:00
Filipe Laíns
157f271de3
gh-139899: Introduce MetaPathFinder.discover and PathEntryFinder.discover (#139900)
* gh-139899: Introduce MetaPathFinder.discover and PathEntryFinder.discover

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Fix doc reference

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Remove specific doc references

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Fix docstrings

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Revert "Remove specific doc references"

This reverts commit 31d1a8f551.

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Fix news references

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Add docs warning

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Raise ValueError on invalid parent

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Dedupe __path__ in PathFinder.discover

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Use context manager and add error handling to os.scandir

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Raise ValueError on invalid parent

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Dedupe when package exists with multiple suffixes

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Apply suggestions from code review

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>

* Add tests

Signed-off-by: Filipe Laíns <lains@riseup.net>

---------

Signed-off-by: Filipe Laíns <lains@riseup.net>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
Co-authored-by: Brett Cannon <brett@python.org>
2026-02-19 15:25:50 +00:00
Mark Shannon
3f37b94c73
GH-144651: Optimize the new uops added when recording values during tracing. (GH-144948)
* Handle dependencies in the optimizer, not the tracer
* Strengthen some checks to avoid relying on optimizer for correctness
2026-02-19 11:52:57 +00:00
Victor Stinner
0bbdb4e897
gh-141510: Replace MappingProxyType with frozendict (#144904) 2026-02-18 20:23:49 +00:00
Victor Stinner
16ccdbc50a
gh-141510: Fix frozendict.fromkeys() for dict subclasses (#144962)
Copy also the dictionary if a dict subclass returns a frozendict.
2026-02-18 18:03:04 +01:00
Donghee Na
3e2f5c133f
gh-141510: Update specializer to support frozendict (gh-144949) 2026-02-19 01:10:53 +09:00
Serhiy Storchaka
a18e0fa4c0
gh-135573: Add tests for pickle opcodes with wrong types (GH-144950)
Ensure that APPENDS and ADDITEMS raise error for wrong collection even
with empty items.
2026-02-18 18:02:12 +02:00
Victor Stinner
c582ff3c25
gh-141510: Fix frozendict.fromkeys() for subclasses (#144952)
Copy the frozendict if needed.
2026-02-18 15:56:09 +00:00
Victor Stinner
f705486745
gh-141510: Add frozendict fast-path to the set type (#144912) 2026-02-18 15:25:47 +01:00
Ruslan Gilfanov
1636630390
gh-124748: Fix handling kwargs in WeakKeyDictionary.update() (#124783) 2026-02-18 13:17:08 +00:00
Serhiy Storchaka
3f50432e31
gh-140652: Fix a crash in _interpchannels.list_all() after closing a channel (ПР-143743) 2026-02-18 14:54:48 +02:00
Pieter Eendebak
dd64e4260e
gh-141510: Implement copy and deepcopy for frozendict (#144905)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-02-18 12:30:26 +01:00
Stan Ulbrych
e49bfca87c
gh-142224: unicodedata: support bidi classes for unassigned code points (GH-144815) 2026-02-18 12:54:07 +02:00
Victor Stinner
e779777c66
gh-141510: Mention frozendict in dict documentation (#144934)
test_genericalias now tests also frozendict.
2026-02-17 23:03:22 +01: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
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
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
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
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
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
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