Thomas Grainger [Wed, 15 Jan 2025 13:05:59 +0000 (13:05 +0000)]
gh-128816: Fix warnings in test_doctest (GH-128817)
* Fix a deprecation warning for using importlib.resources.abc.ResourceReader.
* Fix an import warning when importing readline (if it has not yet been imported).
Yan Yanchii [Wed, 15 Jan 2025 09:38:43 +0000 (10:38 +0100)]
gh-128438: Use `EnvironmentVarGuard` for `test_{builtin,io,locale}.py` (#128476)
Modifying locale-related environment variables in `Lib/test/test_builtin.py`,
`Lib/test/test_io.py` and `Lib/test/test_locale.py` is now achieved by using
an `EnvironmentVarGuard` context instead of an explicit `try-finally` block.
Bénédikt Tran [Tue, 14 Jan 2025 13:25:33 +0000 (14:25 +0100)]
gh-118761: substitute `re` import in `base64.b16decode` for a more efficient alternative (#128736)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Chris Markiewicz <effigies@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Serhiy Storchaka [Tue, 14 Jan 2025 08:02:38 +0000 (10:02 +0200)]
gh-71339: Add additional assertion methods for unittest (GH-128707)
Add the following methods:
* assertHasAttr() and assertNotHasAttr()
* assertIsSubclass() and assertNotIsSubclass()
* assertStartsWith() and assertNotStartsWith()
* assertEndsWith() and assertNotEndsWith()
Also improve error messages for assertIsInstance() and
assertNotIsInstance().
Bénédikt Tran [Mon, 13 Jan 2025 16:58:11 +0000 (17:58 +0100)]
gh-125997: Increase test coverage for `time.sleep()` (#128751)
- Add tests for durations of invalid types.
- Add tests for `int` and `float` durations, including signed zeroes durations.
- Add tests for nonzero very small durations and durations close to the clock resolution.
---------
Co-authored-by: Victor Stinner <vstinner@python.org>
Bénédikt Tran [Mon, 13 Jan 2025 11:46:13 +0000 (12:46 +0100)]
gh-128150: Improve performances of `uuid.uuid*` constructor functions. (#128151)
We introduce a private constructor `UUID._from_int()` for RFC 4122/9562 UUIDs,
which takes the integral UUID value as input. The latter must have correctly set
its variant and version bits. We also make `UUID.__init__()` slightly more efficient.
Hood Chatham [Sun, 12 Jan 2025 23:09:39 +0000 (00:09 +0100)]
gh-128627: Emscripten: Use wasm-gc based call adaptor if available (#128628)
Replaces the trampoline mechanism in Emscripten with an implementation that uses a
recently added feature of wasm-gc instead of JS type reflection, when that feature is
available.
Yan Yanchii [Sun, 12 Jan 2025 08:27:28 +0000 (09:27 +0100)]
gh-128377: Skip `test_cmd_line.test_non_interactive_output_buffering` when `PYTHONUNBUFFERED=1` (#128378)
The `test_cmd_line.test_non_interactive_output_buffering` test assumes a buffered `stdio`
without checking the `PYTHONUNBUFFERED` value. Instead of changing the environment
variable for the duration of the test, it is better to simply skip it.
Barney Gale [Sat, 11 Jan 2025 19:27:47 +0000 (19:27 +0000)]
GH-128520: Divide pathlib ABCs into three classes (#128523)
In the private pathlib ABCs, rename `PurePathBase` to `JoinablePath`, and
split `PathBase` into `ReadablePath` and `WritablePath`. This improves the
API fit for read-only virtual filesystems.
The split of `PathBase` entails a similar split of `CopyWorker` (implements
copying) and the test cases in `test_pathlib_abc`.
In a later patch, we'll make `WritablePath` inherit directly from
`JoinablePath` rather than `ReadablePath`. For a couple of reasons,
this isn't quite possible yet.
Petr Viktorin [Fri, 10 Jan 2025 12:59:51 +0000 (13:59 +0100)]
gh-127257: Add hex code to ssl "unknown error" message (GH-127360)
* ssl: Add hex error code to "unknown error" messages
To make it easier to vary the individual parts of the message,
replace the if-ladder with constant format strings by building
the string piece-wise with PyUnicodeWriter.
Use "unknown error (0x%x)" rather than just "unknown error" if we
can't get a better error message. (Hex makes sense as the error
includes two packed parts.)
Paulie Peña [Fri, 10 Jan 2025 12:52:19 +0000 (07:52 -0500)]
gh-128388: pyrepl on Windows: add meta and ctrl+arrow keybindings (GH-128389)
Fix `Lib/_pyrepl/windows_console.py` to support more keybindings, like the
`Ctrl`+`←` and `Ctrl`+`→` word-skipping keybindings and those with meta (i.e. Alt),
e.g. to `kill-word` or `backward-kill-word`.
Specifics: if Ctrl is pressed, emit "ctrl left" and "ctrl right" instead of just "left" or
"right," and if Meta/Alt is pressed, emit the special key code for meta before
emitting the other key that was pressed.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Sam Gross [Fri, 10 Jan 2025 00:59:10 +0000 (19:59 -0500)]
gh-128691: Use deferred reference counting on `_thread._local` (#128693)
This change, along with the LOAD_ATTR specializations, makes the
"thread_local_read" micro benchmark in Tools/ftscalingbench/ftscalingbench.py
scale well to multiple threads.