Commit graph

55480 commits

Author SHA1 Message Date
Justin Bronder
e3ea861351
gh-135444: fix asyncio.DatagramTransport.sendto to account for datagram header size when data cannot be sent (#135445)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-07-30 23:41:28 +05:30
Serhiy Storchaka
9d3b53c47f
gh-71189: Support all-but-last mode in os.path.realpath() (GH-117562) 2025-07-30 10:19:19 +03:00
Neil Schemenauer
5236b0281b
GH-116738: document thread-safety of bisect (GH-136555) 2025-07-30 02:44:10 +00:00
Sam Gross
98d462cf4d
gh-137179: Fix flaky test_history_survive_crash test (gh-137180)
Kill the REPL subprocess once it prints the output from the command
immediately before the `time.sleep()`.
2025-07-29 14:25:50 -04:00
Ron Frederick
377b787618
gh-136306: Add support for getting and setting SSL groups (#136307)
Add support for getting and setting groups used for key agreement.

* `ssl.SSLSocket.group()` returns the name of the group used
  for the key agreement of the current session establishment.
  This feature requires Python to be built with OpenSSL 3.2 or later.

* `ssl.SSLContext.get_groups()` returns the list of names of groups
  that are compatible with the TLS version of the current context.
  This feature requires Python to be built with OpenSSL 3.5 or later.

* `ssl.SSLContext.set_groups()` sets the groups allowed for key agreement
  for sockets created with this context. This feature is always supported.
2025-07-28 19:33:31 +02:00
Alexander Urieles
7040aa54f1
gh-130577: tarfile now validates archives to ensure member offsets are non-negative (GH-137027)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-07-28 08:37:26 -07:00
Barney Gale
2bd4ff0700
GH-128520: pathlib ABCs: tweak protocol for virtual path strings (#134104)
Adjust `pathlib._os.vfspath()` so that it doesn't try `os.fsdecode()`. I
don't know that supporting `os.PathLike` arguments is a good idea, so
it's best to leave it out for now.
2025-07-27 12:47:15 +01:00
Barney Gale
10a925c86d
GH-137059: url2pathname(): fix support for drive letter in netloc (#137060)
Support file URLs like `file://c:/foo` in `urllib.request.url2pathname()`
on Windows. This restores behaviour from 3.13.
2025-07-27 11:44:41 +00:00
Pablo Galindo Salgado
a852c7bdd4
gh-131038: Use text=True in subprocesses in test_perf_profiler (#137117) 2025-07-26 18:01:51 +01:00
Bénédikt Tran
d658b9053b
gh-136912: fix handling of OverflowError in hmac.digest (#136917)
The OpenSSL and HACL* implementations of HMAC single-shot
digest computation reject keys whose length exceeds `INT_MAX`
and `UINT32_MAX` respectively. The OpenSSL implementation
also rejects messages whose length exceed `INT_MAX`.

Using such keys in `hmac.digest` previously raised an `OverflowError`
which was propagated to the caller. This commit mitigates this case by
making `hmac.digest` fall back to HMAC's pure Python implementation
which accepts arbitrary large keys or messages.

This change only affects the top-level entrypoint `hmac.digest`, leaving
`_hashopenssl.hmac_digest` and `_hmac.compute_digest` untouched.
2025-07-26 08:22:06 +00:00
Savannah Bailey
f7c380ef67
GH-132732: Use pure op machinery to optimize COMPARE_OP_INT/FLOAT/STR (#137062)
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2025-07-25 19:02:04 -07:00
Peter Bierma
e047a35b23
gh-134698: Hold a lock when the thread state is detached in ssl (GH-134724)
Lock when the thread state is detached.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-07-25 08:16:05 -07:00
Tyler Kennedy
cb93b6fc5e
gh-130522: Fix unraisable TypeError in threading at interpreter shutdown (#131537)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-07-25 14:51:30 +00:00
Bénédikt Tran
7ce2f101c4
gh-136929: ensure that hashlib.<name> does not raise AttributeError (#136933)
Previously, if OpenSSL was not present and built-in cryptographic extension modules
were disabled, requesting `hashlib.<name>` raised `AttributeError` and an ERROR log
message with the exception traceback is emitted when importing `hashlib`. 

Now, the named constructor function will always be available but raises a `ValueError`
at runtime indicating that the algorithm is not supported. The log message has also
been reworded to be less verbose.
2025-07-25 14:49:09 +00:00
Raymond Hettinger
ea06ae5b5e
Fix Queue.shutdown docs for condition to unblock a join (gh-137088) 2025-07-25 07:56:28 -06:00
Denis Laxalde
fece15d29f
gh-136914: Fix support of cached functions and properties in DocTest's lineno computation (GH-136930)
Previously, DocTest's lineno of functions and methods decorated with
functools.cache(), functools.lru_cache() and functools.cached_property()
was not properly returned (None was returned) because the
computation relied on inspect.isfunction() which does not consider the
decorated result as a function.

We now use the more generic inspect.isroutine(), as elsewhere
in doctest's logic.

Also, added a special case for functools.cached_property().
2025-07-25 12:46:12 +03:00
Zachary Ware
d5e75c0768
Exclude _testclinic_depr.c.h from c-analyzer (GH-137086)
_testclinic.c mocks out PY_VERSION_HEX to 3.8 before including
_testclinic_depr.c.h to avoid the errors the preprocessor would
otherwise throw due to the deprecation feature it is testing.

Also partially revert 74e2acddf6:
this restores Modules/_testclinic.c to match the same file in the 3.14
branch.
2025-07-24 15:50:01 -05:00
Raymond Hettinger
245671555b
Fix docs for Queue.shutdown (gh-137028) 2025-07-24 11:23:03 -06:00
FredericDT
dc27218225
gh-136980: Remove unused C tracing code in bdb (#136981) 2025-07-24 09:58:54 +09:00
Rogdham
a10235ea67
gh-132983: Add missing references to Zstandard in shutil docstrings (GH-136617)
Zstd references in shutil docstrings
2025-07-23 18:09:53 +00:00
Jelle Zijlstra
6a285f94c6
Revert "gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (#136893)" (#137014)
This reverts commit 46cbdf967a.
2025-07-23 08:13:19 -07:00
sobolevn
99cdf1deb6
gh-136437: Make several functions in os.path pos-only (#136949) 2025-07-23 14:56:02 +03:00
Ani
aafb1435d8
Use test.support.is_wasm32 flag for is_emscripten or is_wasi for generic checks (GH-136815)
Co-authored-by: Brett Cannon <brett@python.org>
2025-07-22 12:50:13 -07:00
Nazım Can Altınova
a667800558
gh-136459: Add perf trampoline support for macOS (#136461) 2025-07-22 16:47:24 +01:00
Serhiy Storchaka
3a89dfe32b
Revert "gh-112068: C API: Add support of nullable arguments in PyArg_Parse (GH-121303)" (#136991) 2025-07-22 16:39:50 +03:00
Pablo Galindo Salgado
aafbdb5df5
gh-133742: Fix test_sysconfig and test_build_details for relocated directories (#136987) 2025-07-22 11:53:05 +00:00
Timon Viola
4d02f31cdd
gh-118350: Fix support of elements "textarea" and "title" in HTMLParser (#135310)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-07-22 13:27:13 +02:00
Hood Chatham
c933a6bb32
gh-124621: Emscripten: Support pyrepl in browser (GH-136931)
Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented

As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.

Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Éric <merwok@netwok.org>
2025-07-22 12:13:38 +02:00
Jelle Zijlstra
46cbdf967a
gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (#136893)
An interesting hack, but more localized in scope than #135230.

This may be a breaking change if people intentionally keep the original class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
original class.

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2025-07-21 21:43:34 -07:00
Emma Smith
6bf1c0ab34
gh-136170: Revert adding ZipFile.data_offset (GH-136950)
* Revert "gh-84481: Make ZipFile.data_offset more robust (#132178)"

This reverts commit 6cd1d6c6b1.

* Revert "gh-84481: Add ZipFile.data_offset attribute (#132165)"

This reverts commit 0788948dcb.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-07-21 23:16:30 +00:00
Peter Bierma
a10960699a
gh-136421: Load _datetime static types during interpreter initialization (GH-136583)
`_datetime` is a special module, because it's the only non-builtin C extension that contains static types. As such, it would initialize static types in the module's execution function, which can run concurrently. Since static type initialization is not thread-safe, this caused crashes. This fixes it by moving the initialization of `_datetime`'s static types to interpreter startup (where all other static types are initialized), which is already properly protected through other locks.
2025-07-21 13:47:26 -04:00
Barney Gale
80b2d60a51
GH-136874: url2pathname(): discard query and fragment components (#136875)
In `urllib.request.url2pathname()`, ignore any query or fragment components
in the given URL.
2025-07-21 17:33:20 +00:00
Alper
65893c6f9c
gh-116738: Make syslog module thread-safe (#136760)
Make the setlogmask() function in the syslog module thread-safe. These changes are relevant for scenarios where the GIL is disabled or when using subinterpreters.
2025-07-21 09:24:42 -07:00
Mikhail Efimov
58d305cf38
gh-136438: Make sure test_generated_cases pass with all optimization levels (#136594)
Fix the `test_generated_cases` to work with `-O` or `-OO` flags.
Previously, `test_generated_cases` was catching an `AssertionError` while `Tools/cases_generator/optimizer_generator.py` used an `assert` statement.  This approach semantically incorrect, no one should trying to catch an `AssertionError`!
Now the `assert` statement has been replaced with an explicit `raise ValueError(...)` and the corresponding `self.assertRaisesRegex(AssertionError, ...)` has been updated to catch a `ValueError` instead.
2025-07-21 15:25:25 +03:00
Petr Viktorin
28153fec58
gh-135621: Simplify TermInfo (GH-136916) 2025-07-21 13:06:42 +02:00
Serhiy Storchaka
dee6501894
gh-135661: Fix parsing attributes with whitespaces around the "=" separator in HTMLParser (GH-136908)
This fixes a regression introduced in GH-135930.
2025-07-21 12:07:15 +02:00
Łukasz Langa
09dfb50f1b
gh-135621: Remove dependency on curses from PyREPL (GH-136758) 2025-07-21 11:57:34 +02:00
Dave Peck
c5e77af131
gh-132661: Disallow Template/str concatenation after PEP 750 spec update (#135996)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2025-07-21 08:44:26 +02:00
AN Long
246be21de1
gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472)
The OS thread name is now correctly prefixed with `InterpreterPoolExecutor` instead of `ThreadPoolExecutor`.
2025-07-20 23:34:32 +00:00
Pablo Galindo Salgado
acbe896cb1
GH-130645: Default to color help in argparse (#136809)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-07-20 14:55:44 -07:00
Peter Bierma
8f59fbb082
gh-136492: Add FrameLocalsProxyType to types (GH-136546)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-07-20 20:49:00 +02:00
morotti
e24c66d55a
gh-91349: Adjust default compression level to 6 (down from 9) in gzip and tarfile (GH-131470)
gh-91349: Adjust default compression level to 6 (down from 9) in gzip and tarfile

It is the default level used by most compression tools and a
better tradeoff between speed and performance.

Co-authored-by: rmorotti <romain.morotti@man.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2025-07-20 09:43:40 -07:00
Alexander Urieles
958657bbc3
gh-131724: Add a new max_response_headers param to HTTP/HTTPSConnection (GH-136814)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-07-20 13:53:54 +00:00
MonadChains
18a7f5dad8
gh-127598: Improve ModuleNotFoundError when -S is passed (GH-136821) 2025-07-20 15:33:58 +02:00
Bénédikt Tran
c504f62fe2
gh-136547: fix hashlib_helper for blocking and requesting digests (#136762)
- Fix `hashlib_helper.block_algorithm` where the dummy functions were incorrectly defined.
- Rename `hashlib_helper.HashAPI` to `hashlib_helper.HashInfo` and add more helper methods.
- Simplify `hashlib_helper.requires_*()` functions.
- Rewrite some private helpers in `hashlib_helper`.
- Remove `find_{builtin,openssl}_hashdigest_constructor()` as they are no more needed and were
  not meant to be public in the first place.
- Fix some tests in `test_hashlib` when FIPS mode is on.
2025-07-20 14:32:35 +02:00
Dominic H.
c6e6fe92cd
gh-130655: gettext: Add fallback testcase (#136857) 2025-07-20 14:08:13 +02:00
Olga Pustovalova
588d9fb84a
gh-136438: Make sure test_remote_pdb pass with all optimization levels (GH-136788) 2025-07-20 10:57:54 +02:00
Bénédikt Tran
6be49ee517
gh-136787: improve exception messages for invalid hash algorithms (#136802) 2025-07-20 08:49:34 +00:00
Disconnect3d
69ea1b3a8f
gh-136839: Refactor simple dict.update calls (#136811)
Refactor simple dict.update calls

This commit refactors simple `dict.update({key: value})` calls which can
be done via `dict[key] = value` instead.

I found those cases with the [semgrep](https://semgrep.dev/) tool:

```
$ semgrep --lang python --pattern '$DICT.update({$A: ...})'

┌─────────────────┐
│ 5 Code Findings │
└─────────────────┘

    Lib/dataclasses.py
         1268┆ slots.update({slot: doc})

    Lib/multiprocessing/resource_tracker.py
           50┆ _CLEANUP_FUNCS.update({
           51┆     'semaphore': _multiprocessing.sem_unlink,
           52┆ })
            ⋮┆----------------------------------------
           53┆ _CLEANUP_FUNCS.update({
           54┆     'shared_memory': _posixshmem.shm_unlink,
           55┆ })

    Lib/tkinter/scrolledtext.py
           26┆ kw.update({'yscrollcommand': self.vbar.set})

    Lib/xmlrpc/server.py
          242┆ self.funcs.update({'system.multicall' : self.system_multicall})
```
2025-07-19 10:12:10 -07:00
sobolevn
67036f1ee1
gh-133875: Remove deprecated pathlib.PurePath.is_reserved (#133876) 2025-07-19 17:07:46 +00:00