Commit graph

13810 commits

Author SHA1 Message Date
Bénédikt Tran
3185e3115c
gh-131277: allow EnvironmentVarGuard to unset more than one environment variable at once (#131280)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-16 14:09:33 +01:00
donBarbos
9558d22ac3
gh-130160: use .. program:: directive for documenting doctest CLI (#131034)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-16 11:53:22 +00:00
donBarbos
7ae9c5dd25
gh-130160: use .. program:: directive for documenting http.server CLI (#131010) 2025-03-15 18:28:56 +02:00
Tian Gao
27fc62cf4f
gh-121468: Add current asyncio task as a convenience variable in pdb (#124367) 2025-03-14 14:46:26 -04:00
Hugo van Kemenade
77b2c933ca Python 3.14.0a6 2025-03-14 17:05:02 +02:00
donBarbos
f9d0531a8d
gh-93096: Update and document pickle CLI (#131097)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-14 14:15:35 +01:00
Stan Ulbrych
e4ac196aaa
gh-124269: Simplify typing.Annotated docs (#130770)
---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-14 10:46:57 +01:00
donBarbos
3a189af4b2
gh-93096: Remove CLI interface for difflib (#131099) 2025-03-13 13:22:16 +02:00
Oleg Iarygin
328f8b8856
gh-93096: Make mimetypes CLI tool public (#93097)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-13 13:19:22 +02:00
Enzo Bonnal
a005835f69
gh-74028: add buffersize parameter to concurrent.futures.Executor.map for lazier behavior (#125663)
`concurrent.futures.Executor.map` now supports limiting the number of submitted
tasks whose results have not yet been yielded via the new `buffersize` parameter.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-13 11:57:53 +01:00
Daniel Pope
e0637cebe5
gh-129349: Accept bytes in bytes.fromhex()/bytearray.fromhex() (#129844)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-12 11:40:11 +01:00
Gerardwx
e0bc9d2a0c
Replace link to historical TypedDict PEP with current document on typing.python… (#131096)
* Replace link to historical PEP with current document on typing.python.org

* Update Doc/library/typing.rst

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>

---------

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
2025-03-11 12:45:31 -04:00
Yuki Kobayashi
7cc99a54b7
gh-101100: Fix sphinx warnings in library/asyncio-subprocess.rst (#130994) 2025-03-10 12:38:08 +00:00
Stan Ulbrych
98fa4a49fe
gh-80421: Correct definitions of time (#130984)
Based on the Wikipedia article, UTC is better said to be a successor than a renaming of GTC and language agnostic rather than an English-French compromise.
2025-03-09 16:09:23 -04:00
donBarbos
c240c2d88a
gh-130160: use .. program:: directive for documenting pdb CLI (#130996) 2025-03-09 11:55:23 -04:00
donBarbos
92e5f826ac
gh-130160: use .. program:: directive for documenting webbrowser CLI (#130995)
use `.. program::` directive for documenting `webbrowser` CLI
2025-03-09 09:57:59 +03:00
Affan Shaikhsurab
a3990df612
gh-123726: Document caveats of zipfile.Path around name sanitization (#130537)
Add a note to the `zipfile.Path` class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references the `extract` and `extractall` methods for comparison and suggests using `os.path.abspath` and `os.path.commonpath` for safe filename resolution.
2025-03-08 16:37:05 -05:00
morotti
b1b4f9625c
gh-117151: IO performance improvement, increase io.DEFAULT_BUFFER_SIZE to 128k (GH-118144)
Co-authored-by: rmorotti <romain.morotti@man.com>
2025-03-07 11:36:12 -08:00
Sebastian Rittau
c6dd2348ca
gh-127647: Add typing.Reader and Writer protocols (#127648) 2025-03-06 07:36:19 -08:00
Bartosz Sławecki
293fa3433e
gh-85795: Raise a clear error when super() is used in typing.NamedTuple subclasses (#130082) 2025-03-05 20:45:47 -08:00
Charles Machalow
ba05a4ebcb
gh-128041: Add terminate_workers and kill_workers methods to ProcessPoolExecutor (GH-130849)
This adds two new methods to `multiprocessing`'s `ProcessPoolExecutor`:
- **`terminate_workers()`**: forcefully terminates worker processes using `Process.terminate()`
- **`kill_workers()`**: forcefully kills worker processes using `Process.kill()`

These methods provide users with a direct way to stop worker processes without `shutdown()` or relying on implementation details, addressing situations where immediate termination is needed.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Sam Gross @colesbury
Commit-message-mostly-authored-by: Claude Sonnet 3.7 (because why not -greg)
2025-03-05 14:31:42 -08:00
Sebastian Rittau
4f6218959e
Update links from typing.readthedocs.io to typing.python.org (#130877) 2025-03-05 17:26:44 +02:00
Jelle Zijlstra
dc6d66f44c
gh-105499: Merge typing.Union and types.UnionType (#105511)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2025-03-04 11:44:19 -08:00
Tomas R.
e091520fdb
gh-126085: Add tp_iter to TypeAliasType to allow star unpacking (#127981) 2025-03-04 11:34:59 -08:00
Tian Gao
63b6ec31c4
gh-82987: Stop on calling frame unconditionally for inline breakpoints (#130493) 2025-03-04 11:35:47 -05:00
Sam Gross
efadc5874c
Revert "gh-128041: Add terminate_workers and kill_workers methods to ProcessPoolExecutor (GH-128043)" (#130838)
The test_concurrent_futures.test_process_pool test is failing in CI.

This reverts commit f97e4098ff.
2025-03-04 11:19:06 -05:00
sobolevn
63ffb406bb
gh-129567: Add a note to typing.TypedDict docs about name mangling (#130233) 2025-03-04 18:15:00 +03:00
Bénédikt Tran
3929af5e3a
gh-89083: add support for UUID version 7 (RFC 9562) (#121119)
Add support for generating UUIDv7 objects according to RFC 9562, §5.7 [1].

The functionality is provided by the `uuid.uuid7()` function. The implementation
is based on a 42-bit counter as described by Method 1, §6.2 [2] and guarantees
monotonicity within the same millisecond.

[1]: https://www.rfc-editor.org/rfc/rfc9562.html#section-5.7
[2]: https://www.rfc-editor.org/rfc/rfc9562.html#section-6.2

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Éric <merwok@netwok.org>
2025-03-04 10:47:19 +01:00
Yuki Kobayashi
a105f99019
gh-101100: Fix sphinx warnings in library/email.errors.rst (#130774) 2025-03-03 11:56:45 +02:00
Victorien
373eb1b47a
gh-101100: Fix Sphinx documentation warnings in collections.rst (#130629) 2025-03-03 11:46:38 +02:00
Mike Castle
a85eeb9771
gh-129015: Improve disambiguation between NotImplemented and NotImplementedError (#129562)
---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-03-03 09:23:41 +01:00
Charles Machalow
f97e4098ff
gh-128041: Add terminate_workers and kill_workers methods to ProcessPoolExecutor (GH-128043)
This adds two new methods to `multiprocessing`'s `ProcessPoolExecutor`:
- **`terminate_workers()`**: forcefully terminates worker processes using `Process.terminate()`
- **`kill_workers()`**: forcefully kills worker processes using `Process.kill()`

These methods provide users with a direct way to stop worker processes without `shutdown()` or relying on implementation details, addressing situations where immediate termination is needed.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Commit-message-mostly-authored-by: Claude Sonnet 3.7 (because why not -greg)
2025-03-02 18:01:45 -08:00
Bénédikt Tran
c6513f7a62
gh-128481: indicate that the default value for FrameSummary.end_lineno changed in 3.13 (#130755)
The value taken by `FrameSummary.end_lineno` when passing `end_lineno=None` changed in gh-112097.

Previously, a `end_lineno` could be specified to be `None` directly but since 939fc6d, passing None makes
the constructor use the value of `lineno` instead.
2025-03-02 18:16:51 +01:00
Bénédikt Tran
990ad272f6
gh-89083: add support for UUID version 6 (RFC 9562) (#120650)
Add support for generating UUIDv6 objects according to RFC 9562, §5.6 [1].

The functionality is provided by the `uuid.uuid6()` function which takes as inputs an optional 48-bit
hardware address and an optional 14-bit clock sequence. The UUIDv6 temporal fields are ordered
differently than those of UUIDv1, thereby providing improved database locality.

[1]: https://www.rfc-editor.org/rfc/rfc9562.html#section-5.6

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-02 12:41:56 +01:00
Damien
051f0e5683
gh-128481: Improve documentation for traceback.FrameSummary (#128484)
Complete the `traceback.FrameSummary` signature and add missing
documentation for the `colno` and `end_{col,line}no` attributes.
2025-03-02 10:29:12 +01:00
Tim Hoffmann
c71e55869e
Add link in the importlib.metadata.version() docs (#130739)
Link the specification for the returned data makes it clearer what this is
and what the format of the version string can be.
2025-03-02 10:23:32 +01:00
Apostol Fet
5181ddb29f
gh-130160: use .. program:: directive for documenting cProfile CLI (#130314)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-03-01 23:39:25 +03:00
Barney Gale
5326c27fc6
Revert "GH-116380: Speed up glob.[i]glob() by making fewer system calls. (#116392)" (#130743)
This broke tests on the 'aarch64 Fedora Stable Clang Installed 3.x' and
'AMD64 Fedora Stable Clang Installed 3.x' build bots.

This reverts commit da4899b94a.
2025-03-01 20:04:01 +00:00
Barney Gale
da4899b94a
GH-116380: Speed up glob.[i]glob() by making fewer system calls. (#116392)
## Filtered recursive walk

Expanding a recursive `**` segment entails walking the entire directory
tree, and so any subsequent pattern segments (except special segments) can
be evaluated by filtering the expanded paths through a regex. For example,
`glob.glob("foo/**/*.py", recursive=True)` recursively walks `foo/` with
`os.scandir()`, and then filters paths through a regex based on "`**/*.py`,
with no further filesystem access needed.

This fixes an issue where `glob()` could return duplicate results.

## Tracking path existence

We store a flag alongside each path indicating whether the path is
guaranteed to exist. As we process the pattern:

- Certain special pattern segments (`""`, `"."` and `".."`) leave the flag
  unchanged
- Literal pattern segments (e.g. `foo/bar`) set the flag to false
- Wildcard pattern segments (e.g. `*/*.py`) set the flag to true (because
  children are found via `os.scandir()`)
- Recursive pattern segments (e.g. `**`) leave the flag unchanged for the
  root path, and set it to true for descendants discovered via
  `os.scandir()`.

If the flag is false at the end, we call `lstat()` on each path to filter
out missing paths.

## Minor speed-ups

- Exclude paths that don't match a non-terminal non-recursive wildcard
  pattern _prior_ to calling `is_dir()`.
- Use a stack rather than recursion to implement recursive wildcards.
  - This fixes a recursion error when globbing deep trees.
- Pre-compile regular expressions and pre-join literal pattern segments.
- Convert to/from `bytes` (a minor use-case) in `iglob()` rather than
  supporting `bytes` throughout. This particularly simplifies the code
  needed to handle relative bytes paths with `dir_fd`.
- Avoid calling `os.path.join()`; instead we keep paths in a normalized
  form and append trailing slashes when needed.
- Avoid calling `os.path.normcase()`; instead we use case-insensitive regex
  matching.

## Implementation notes

Much of this functionality is already present in pathlib's implementation
of globbing. The specific additions we make are:

1. Support for `dir_fd`
2. Support for `include_hidden`
3. Support for generating paths relative to `root_dir`

This unifies the implementations of globbing in the `glob` and `pathlib`
modules.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-28 20:33:51 +00:00
Barney Gale
b545450961
GH-130608: Remove dirs_exist_ok argument from pathlib.Path.copy() (#130610)
This feature isn't sufficiently motivated.
2025-02-28 19:29:20 +00:00
Yuki Kobayashi
b26286ca49
Docs: Fix a misplaced statement in the document for ServerProxy (GH-130616)
The sentence "If an HTTPS URL ..." explains what the parameter means,
so moved it to the paragraph explaining what the other parameters mean.
2025-02-27 16:14:56 +01:00
Fredrik Ahlberg
45a24f54af
gh-129288: Add optional l2_cid and l2_bdaddr_type in BTPROTO_L2CAP socket address tuple (#129293)
Add two optional, traling elements in the AF_BLUETOOTH socket address tuple:

- l2_cid, to allow e.g raw LE ATT connections
- l2_bdaddr_type. To be able to connect L2CAP sockets to Bluetooth LE devices,
  the l2_bdaddr_type must be set to BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM.
2025-02-27 12:51:47 +00:00
Yuki Kobayashi
b536e37104
gh-130433: Update documentation for MultipartConversionError (GH-130436) 2025-02-26 08:34:10 +00:00
Sergey B Kirpichev
f39a07be47
gh-87790: support thousands separators for formatting fractional part of floats (#125304)
```pycon
>>> f"{123_456.123_456:_._f}"  # Whole and fractional
'123_456.123_456'
>>> f"{123_456.123_456:_f}"    # Integer component only
'123_456.123456'
>>> f"{123_456.123_456:._f}"   # Fractional component only
'123456.123_456'
>>> f"{123_456.123_456:.4_f}"  # with precision
'123456.1_235'
```
2025-02-25 16:27:07 +01:00
Yuki Kobayashi
4d3a7ea354
Docs: Fix some semantic usages of iterator.__iter__ (GH-130172)
These references to an `__iter__` method mean `object.__iter__`, not `iterator.__iter__`.
2025-02-25 13:38:47 +01:00
Kanishk Pachauri
85f1cc8d60
gh-130461: Remove unnecessary usages of .. index:: directives in Doc/library/uuid.rst (#130526)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-25 14:27:50 +02:00
RUANG (James Roy)
9f25c1f012
gh-46236: Add docs for PyUnicode_GetDefaultEncoding() doc (GH-130335)
* Clarify sys.getdefaultencoding() documentation

* Add missing documentation for PyUnicode_GetDefaultEncoding,
  the C equivalent of sys.getdefaultencoding
2025-02-24 15:37:21 +01:00
Bénédikt Tran
39ba4b6619
gh-127522: wsgiref: indicate that start_response objects should follow a specific protocol (GH-127525) 2025-02-24 13:43:56 +01:00
Kanishk Pachauri
0ff1611574
gh-130160: use .. program:: directive for documenting idle CLI (#130278)
---------
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-24 02:02:34 +00:00
mingyu
9f81f828c7
gh-129948: Add set() to multiprocessing.managers.SyncManager (#129949)
The SyncManager provided support for various data structures such as dict, list, and queue, but oddly, not set.
This introduces support for set by defining SetProxy and registering it with SyncManager.

---
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-02-23 20:07:33 +00:00