Commit Graph

122569 Commits

Author SHA1 Message Date
Adam Williamson d4039d3f6f
gh-120526: Correct signature of map() builtin (GH-120528)
map() requires at least one iterable arg.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2024-06-15 05:33:09 +00:00
Russell Keith-Magee 5c58e728b1
gh-117398: Use the correct module loader for iOS in datetime CAPI test. (#120477)
Use the correct loader for iOS.
2024-06-15 08:05:30 +08:00
Russell Keith-Magee 92f6d400f7
gh-119819: Conditional skip of logging tests that require multiprocessing subprocess support (#120476)
Skip tests that require multiprocessing subprocess support.
2024-06-15 08:05:18 +08:00
Eric Snow e3b6cff331
gh-120524: Temporarily Skip test_create_many_threaded In test_interpreters.test_stress (gh-120525) 2024-06-14 22:12:35 +00:00
Eric Snow b2e71ff4f8
gh-120161: Fix a Crash in the _datetime Module (gh-120182)
In gh-120009 I used an atexit hook to finalize the _datetime module's static types at interpreter shutdown.  However, atexit hooks are executed very early in finalization, which is a problem in the few cases where a subclass of one of those static types is still alive until the final GC collection.  The static builtin types don't have this probably because they are finalized toward the end, after the final GC collection.  To avoid the problem for _datetime, I have applied a similar approach here.

Also, credit goes to @mgorny and @neonene for the new tests.

FYI, I would have liked to take a slightly cleaner approach with managed static types, but wanted to get a smaller fix in first for the sake of backporting.  I'll circle back to the cleaner approach with a future change on the main branch.
2024-06-14 13:29:09 -06:00
Victor Stinner 05df063ad8
gh-120417: Fix "imported but unused" linter warnings (#120461)
Add __all__ to the following modules:
importlib.machinery, importlib.util and xml.sax.

Add also "# noqa: F401" in collections.abc,
subprocess and xml.sax.

* Sort __all__; remove collections.abc.__all__; remove private names

* Add tests
2024-06-14 20:39:50 +02:00
Tian Gao ed60ab5fab
gh-119824: Print stack entry when user input is needed (#119882)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-06-14 11:25:23 -07:00
Nikita Sobolev 7fadfd82eb
gh-120361: Add `nonmember` test with enum flags inside to `test_enum` (GH-120364)
* gh-120361: Add `nonmember` test with enum flags inside to `test_enum`
2024-06-14 10:25:35 -07:00
Barney Gale 7c38097add
GH-73991: Add `pathlib.Path.copy()` (#119058)
Add a `Path.copy()` method that copies the content of one file to another.

This method is similar to `shutil.copyfile()` but differs in the following ways:

- Uses `fcntl.FICLONE` where available (see GH-81338)
- Uses `os.copy_file_range` where available (see GH-81340)
- Uses `_winapi.CopyFile2` where available, even though this copies more metadata than the other implementations. This makes `WindowsPath.copy()` more similar to `shutil.copy2()`.

The method is presently _less_ specified than the `shutil` functions to allow OS-specific optimizations that might copy more or less metadata.

Incorporates code from GH-81338 and GH-93152.

Co-authored-by: Eryk Sun <eryksun@gmail.com>
2024-06-14 17:15:49 +01:00
AN Long 2bacc2343c
gh-117657: Add TSAN suppression for set_default_allocator_unlocked (#120500)
Add TSAN suppression for set_default_allocator_unlocked
2024-06-15 00:10:18 +08:00
Raymond Hettinger 27419f1fce
Update tests for the itertools docs rough equivalents (#120509) 2024-06-14 11:00:46 -05:00
Raymond Hettinger 41554ef0e0
Stronger tests for the statistics kernel formulas (gh-120506) 2024-06-14 10:21:35 -05:00
Alex Waygood 42351c3b9a
gh-114053: Fix bad interaction of PEP 695, PEP 563 and `inspect.get_annotations` (#120270) 2024-06-13 21:16:40 +00:00
Barney Gale d88a1f2e15
GH-119054: Add "Renaming and deleting" section to pathlib docs. (#120465)
Add dedicated subsection for `pathlib.Path.rename()`, `replace()`,
`unlink()` and `rmdir()`.
2024-06-13 21:25:26 +01:00
Bénédikt Tran a3711afefa
gh-120012: clarify the behaviour of `multiprocessing.Queue.empty` on closed queues. (GH-120102)
* improve doc for `multiprocessing.Queue.empty`
* add tests for checking emptiness of queues

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-06-13 19:03:01 +00:00
Erlend E. Aasland 6674c63dc7
Add codeowner for Makefile.pre.in and Modules/Setup* (#120468) 2024-06-13 19:01:05 +00:00
neonene 50a389565a
gh-117398: Add datetime C-API type check test for subinterpreters (gh-119604)
Check if the DateTime C-API type matches the datetime.date type on main and shared/isolated subinterpreters.
2024-06-13 12:05:03 -06:00
Barney Gale c2d810b6d4
GH-119054: Add "Creating files and directories" section to pathlib docs. (#120186)
Add dedicated subsection for `pathlib.Path.touch()`, `mkdir()`,
`symlink_to()` and `hardlink_to()`. Also note that `open()`, `write_text()`
and `write_bytes()` are often used to create files.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-06-13 17:58:46 +00:00
Kirill Podoprigora 6af190f8d0
gh-120397: Fix typo in NEWS entry (#120455) 2024-06-13 18:53:45 +02:00
Ruben Vorderman 2078eb45ca
gh-120397: Optimize str.count() for single characters (#120398) 2024-06-13 16:28:59 +02:00
Victor Stinner 6ae254aaa0
gh-120417: Add #noqa to used imports in the stdlib (#120421)
Tools such as ruff can ignore "imported but unused" warnings if a
line ends with "# noqa: F401". It avoids the temptation to remove
an import which is used effectively.
2024-06-13 16:14:50 +02:00
Kirill Podoprigora ca5108a46d
gh-119146: Update ``regexp`` in `build.yml` to not trigger the jobs on `*.md` and `*.ini` files. (#120435)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-06-13 14:38:31 +03:00
Xie Yanbo 87cedaa5c8
Fix typos in documentation (GH-120440) 2024-06-13 09:37:21 +00:00
Ken Jin b1b61dc4ce
gh-117657: Fix some simple races in instrumentation.c (GH-120118)
* stop the world when setting local events
2024-06-13 17:31:21 +08:00
Ken Jin eebae2c460
gh-117657: Make PyType_HasFeature atomic (GH-120210)
Make PyType_HasFeature atomic
2024-06-13 17:29:19 +08:00
Stefano Rivera 030b452e34
gh-120418: Don't assume wheeldata is deleted if `WHEEL_PKG_DIR` is set (#120419)
Remove wheeldata from both sides of the `assertEqual`, so that we're
*actually* ignoring it from the test set.

This test is only making assertions about the source tree, no code is
being executed that would do anything different based on the value of
`WHEEL_PKG_DIR`.
2024-06-12 21:19:36 +02:00
Pablo Galindo Salgado 3453362183
gh-118908: Protect the REPL subprocess with a timeout in tests (#120408) 2024-06-12 19:09:25 +00:00
Victor Stinner 4c6d4f5cb3
gh-120417: Remove unused imports in the stdlib (#120420) 2024-06-12 20:56:42 +02:00
Lysandros Nikolaou 4b5d3e0e72
gh-120343: Fix column offsets of multiline tokens in tokenize (#120391) 2024-06-12 20:52:55 +02:00
neonene 127c1d2771
gh-71587: Drop local reference cache to `_strptime` module in `_datetime` (gh-120224)
The _strptime module object was cached in a static local variable (in the datetime.strptime() implementation).  That's a problem when it crosses isolation boundaries, such as reinitializing the runtme or between interpreters.  This change fixes the problem by dropping the static variable, instead always relying on the normal sys.modules cache (via PyImport_Import()).
2024-06-12 10:46:39 -06:00
Nikita Sobolev fabcf6bc8f
gh-120388: Improve deprecation warning message, when test returns non-None (#120401)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-06-12 14:50:58 +00:00
Serhiy Storchaka 92c9c6ae14
gh-120345: Fix incorrect use of the :class: role with the "()" suffix (GH-120347)
* Remove "()" when refer to a class as a type.
* Use :func: when refer to a callable.
* Fix reference to the datetime.astimezone() method.
2024-06-12 17:23:03 +03:00
Victor Stinner 42b25dd61f
gh-120155: Add assertion to sre.c match_getindex() (#120402)
Add an assertion to help static analyzers to detect that i*2 cannot
overflow.
2024-06-12 15:27:07 +02:00
ixgbe00 4b1e85bafc
gh-120400 :Support Linux perf profile to see Python calls on RISC-V architecture (#120089)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2024-06-12 14:24:46 +01:00
Bénédikt Tran 32d3e05fe6
gh-120029: remove unused macros in ``symtable.c`` (#120222)
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-06-12 09:23:45 -04:00
Ken Jin e16aed63f6
gh-117657: Make Py_TYPE and Py_SET_TYPE thread safe (GH-120165)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
2024-06-12 20:41:07 +08:00
Xie Yanbo ce3879bd45
Fix typos in documentation (#120338) 2024-06-12 12:24:43 +00:00
Irit Katriel 97b69db167
gh-93691: fix too broad source locations of for statement iterators (#120330) 2024-06-12 12:53:19 +01:00
Bénédikt Tran 755dab719d
gh-120029: make `symtable.Symbol.__repr__` correctly reflect the compiler's flags, add methods (#120099)
Expose :class:`symtable.Symbol` methods :meth:`~symtable.Symbol.is_free_class`,
:meth:`~symtable.Symbol.is_comp_iter` and :meth:`~symtable.Symbol.is_comp_cell`.

---------

Co-authored-by: Carl Meyer <carl@oddbird.net>
2024-06-12 05:14:50 -06:00
Owain Davies 7dd8c37a06
gh-101575: document Decimal.__round__() (GH-101737) 2024-06-12 12:07:25 +02:00
Lysandros Nikolaou 02e74c3562
gh-118908: Fix completions after namespace change in REPL (#120370) 2024-06-12 10:21:53 +02:00
Kirill Podoprigora 19435d299a
gh-120385: Fix reference leak in symtable (#120386)
Decref 'new_ste' if symtable_visit_annotations() fails.
2024-06-12 09:37:14 +02:00
Nikita Sobolev f5a9c34f38
gh-120056: Add `IP_RECVERR`, `IP_RECVORIGDSTADDR`, `IP_RECVTTL` to `socket` module (#120058)
* gh-120056: Add `IP_RECVERR` and `IP_RECVTTL` to `socket` module

* Fix news

* Address review

* Update NEWS
2024-06-11 21:00:56 -04:00
Pablo Galindo Salgado 34e4d3287e
gh-120221: Deliver real singals on Ctrl-C and Ctrl-Z in the new REPL (#120354) 2024-06-11 20:20:25 +01:00
Ken Jin 203565b2f9
gh-120198: Fix race condition when editing __class__ with an audit hook active (GH-120195) 2024-06-11 20:10:23 +01:00
Kirill Podoprigora 939c201e00
gh-120326: Include <intrin.h> on Windows with Free Threading (#120329) 2024-06-11 19:50:21 +02:00
Eugene Triguba 86a8a1c57a
gh-118908: Limit exposed globals from internal imports and definitions on new REPL startup (#119547) 2024-06-11 17:40:31 +00:00
naglis 0335662fe1
Fix typo in ElementTree docs (#120342) 2024-06-11 20:01:48 +03:00
Lysandros Nikolaou 1b62bcee94
gh-120343: Do not reset byte_col_offset_diff after multiline tokens (#120352)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-06-11 17:00:53 +00:00
Matt Wozniski 32a0faba43
gh-119517: Fixes for pasting in pyrepl (#120253)
* Remove pyrepl's optimization for self-insert

This will be replaced by a less specialized optimization.

* Use line-buffering when pyrepl echoes pastes

Previously echoing was totally suppressed until the entire command had
been pasted and the terminal ended paste mode, but this gives the user
no feedback to indicate that an operation is in progress. Drawing
something to the screen once per line strikes a balance between
perceived responsiveness and performance.

* Remove dead code from pyrepl

`msg_at_bottom` is always true.

* Speed up pyrepl's screen rendering computation

The Reader in pyrepl doesn't hold a complete representation of the
screen area being drawn as persistent state. Instead, it recomputes it,
on each keypress. This is fast enough for a few hundred bytes, but
incredibly slow as the input buffer grows into the kilobytes (likely
because of pasting).

Rather than making some expensive and expansive changes to the repl's
internal representation of the screen, add some caching: remember some
data from one refresh to the next about what was drawn to the screen
and, if we don't find anything that has invalidated the results that
were computed last time around, reuse them. To keep this caching as
simple as possible, all we'll do is look for lines in the buffer that
were above the cursor the last time we were asked to update the screen,
and that are still above the cursor now. We assume that nothing can
affect a line that comes before both the old and new cursor location
without us being informed. Based on this assumption, we can reuse old
lines, which drastically speeds up the overwhelmingly common case where
the user is typing near the end of the buffer.

* Speed up pyrepl prompt drawing

Cache the `can_colorize()` call rather than repeatedly recomputing it.
This call looks up an environment variable, and is called once per
character typed at the REPL. The environment variable lookup shows up as
a hot spot when profiling, and we don't expect this to change while the
REPL is running.

* Speed up pasting multiple lines into the REPL

Previously, we were checking whether the command should be accepted each
time a line break was encountered, but that's not the expected behavior.
In bracketed paste mode, we expect everything pasted to be part of
a single block of code, and encountering a newline shouldn't behave like
a user pressing <Enter> to execute a command. The user should always
have a chance to review the pasted command before running it.

* Use a read buffer for input in pyrepl

Previously we were reading one byte at a time, which causes much slower
IO than necessary. Instead, read in chunks, processing previously read
data before asking for more.

* Optimize finding width of a single character

`wlen` finds the width of a multi-character string by adding up the
width of each character, and then subtracting the width of any escape
sequences. It's often called for single character strings, however,
which can't possibly contain escape sequences. Optimize for that case.

* Optimize disp_str for ASCII characters

Since every ASCII character is known to display as single width, we can
avoid not only the Unicode data lookup in `disp_str` but also the one
hidden in `str_width` for them.

* Speed up cursor movements in long pyrepl commands

When the current pyrepl command buffer contains many lines, scrolling up
becomes slow. We have optimizations in place to reuse lines above the
cursor position from one refresh to the next, but don't currently try to
reuse lines below the cursor position in the same way, so we wind up
with quadratic behavior where all lines of the buffer below the cursor
are recomputed each time the cursor moves up another line.

Optimize this by only computing one screen's worth of lines beyond the
cursor position. Any lines beyond that can't possibly be shown by the
console, and bounding this makes scrolling up have linear time
complexity instead.

---------

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2024-06-11 16:42:10 +00:00