Commit Graph

121588 Commits

Author SHA1 Message Date
Barney Gale 6258844c27
GH-117586: Speed up `pathlib.Path.glob()` by working with strings (#117589)
Move pathlib globbing implementation into a new private class: `glob._Globber`. This class implements fast string-based globbing. It's called by `pathlib.Path.glob()`, which then converts strings back to path objects.

In the private pathlib ABCs, add a `pathlib._abc.Globber` subclass that works with `PathBase` objects rather than strings, and calls user-defined path methods like `PathBase.stat()` rather than `os.stat()`.

This sets the stage for two more improvements:

- GH-115060: Query non-wildcard segments with `lstat()`
- GH-116380: Unify `pathlib` and `glob` implementations of globbing.

No change to the implementations of `glob.glob()` and `glob.iglob()`.
2024-04-10 20:43:07 +01:00
Pablo Galindo Salgado 689ada7915
gh-67224: Make linecache imports relative to improve startup speed (#117501) 2024-04-10 20:09:25 +01:00
Barney Gale 630df37116
GH-117546: Fix symlink resolution in `os.path.realpath('loop/../link')` (#117568)
Continue resolving symlink targets after encountering a symlink loop, which
matches coreutils `realpath` behaviour.
2024-04-10 18:17:18 +01:00
Laurie O 6bc0b33a91
gh-117531: Unblock getters after non-immediate queue shutdown (#117532)
(This is a small tweak of the original gh-104750 which added shutdown.)
2024-04-10 08:01:42 -07:00
Kirill Podoprigora dfcae4379f
gh-115142: Skip ``test_capi.test_dict.py`` if ``_testcapi`` and ``_testlimitedcapi`` are not available (GH-117588)
gh-115142: Skip test_dict if _testcapi and _testlimitedcapi is not available
2024-04-10 16:32:57 +02:00
Sam Gross 79eec66e3d
gh-112536: Define `_Py_THREAD_SANITIZER` on GCC when TSan is enabled (#117702)
The `__has_feature(thread_sanitizer)` is a Clang-ism. Although new
versions of GCC implement `__has_feature`, the `defined(__has_feature)`
check still fails on GCC so we don't use that code path.
2024-04-10 10:20:05 -04:00
neonene ef4118222b
gh-117142: Port _ctypes to multi-phase init (GH-117181) 2024-04-10 11:00:01 +00:00
Nikita Sobolev 4bb7d121bc
gh-117692: Fix `AttributeError` in `DocTestFinder` on wrapped `builtin_or_method` (#117699)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-04-10 10:52:47 +01:00
Nice Zombies f90ff03672
gh-117686: Improve the performance of ntpath.expanduser() (#117690)
Refactor out _get_bothseps() call from the loop.
2024-04-10 10:28:48 +02:00
Erlend E. Aasland 0d42ac9474
gh-117431: Argument Clinic: copy forced text signature when cloning (#117591) 2024-04-10 10:12:05 +02:00
Nice Zombies 73906d5c90
gh-117360: Clearer wording in os.path.lexists() docs (#117679)
Co-authored-by: Zachary Ware <zach@python.org>
2024-04-09 23:00:41 +02:00
Nice Zombies a05068db0c
gh-117597: Clarify exception handling in the tutorial (#117681) 2024-04-09 20:59:45 +00:00
Erlend E. Aasland ca75915779
gh-117648: Amend NEWS entry (#117697)
Make the wording more vague; the performance impact varies a lot
depending on platform and input.
2024-04-09 20:03:47 +00:00
Thomas Wouters d0f93d132f Merge branch 'main' of https://github.com/python/cpython 2024-04-09 20:42:07 +02:00
Thomas Wouters 54084e2fe4 Post 3.13.0a6 2024-04-09 20:40:50 +02:00
Ethan Furman e5521bcca9
gh-117663: [Enum] fix _simple_enum's detection of aliases (GH-117664) 2024-04-09 11:31:07 -07:00
Vlad4896 d5f1139c79
gh-117534: Add checking for input parameter in iso_to_ymd (#117543)
Moves the validation for invalid years in the C implementation of the `datetime` module into a common location between `fromisoformat` and `fromisocalendar`, which improves the error message and fixes a failed assertion when parsing invalid ISO 8601 years using one of the "ISO weeks" formats.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-04-09 13:53:00 -04:00
Victor Stinner a25c02eaf0
Revert "gh-106023: Update What's New in 3.13: _PyObject_FastCall() (#117633)" (#117676)
This reverts commit 9a12f5d1c1.

I was wrong: the _PyObject_FastCall() function was removed. But we
kept the _PyObject_FastCallDict() function.
2024-04-09 18:26:35 +02:00
Sam Gross 6edde8a91c
gh-117658: Fix check_dump_traceback_threads in free-threaded build (#117659)
With the GIL disabled, the waiting thread may still be in the
`self.running.set() ` call when faulthandler dumps tracebacks.
2024-04-09 11:50:49 -04:00
Guido van Rossum fa58e75a86
gh-116720: Fix corner cases of taskgroups (#117407)
This prevents external cancellations of a task group's parent task to
be dropped when an internal cancellation happens at the same time.
Also strengthen the semantics of uncancel() to clear self._must_cancel
when the cancellation count reaches zero.

Co-Authored-By: Tin Tvrtković <tinchester@gmail.com>
Co-Authored-By: Arthur Tacca
2024-04-09 08:17:28 -07:00
Malcolm Smith 22b25d1eba
gh-116622: Enable `test_doctest` on platforms that don't support subprocesses (#116758)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-04-09 14:40:58 +03:00
Jelle Zijlstra f2132fcd2a
gh-117516: Implement typing.TypeIs (#117517)
See PEP 742.

Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-04-09 10:50:37 +00:00
Thomas Wouters 57aee2a02c Python 3.13.0a6 2024-04-09 11:56:22 +02:00
Tian Gao 57183241af
gh-107674: Remove some unnecessary code in instrumentation code (GH-117393) 2024-04-09 09:54:28 +01:00
Nice Zombies 99852d9e65
gh-117648: Improve performance of os.join (#117654)
Replace map() with a method call in the loop body.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2024-04-09 10:27:14 +02:00
Chris Markiewicz 19a2202067
gh-117182: Allow lazily loaded modules to modify their own __class__ 2024-04-09 04:08:48 +01:00
Victor Stinner ac45766673
gh-117645: Skip test_dynamic global specialization on WASI (#117646)
Skip test_load_global_specialization_failure_keeps_oparg() of
test_dynamic on WASI build. The test uses too much stack memory.
2024-04-08 21:11:08 +02:00
Victor Stinner ed785c0899
Enhance regrtest get_signal_name(): support shell exit code (#117647) 2024-04-08 17:16:43 +00:00
Bruce Merry 775912a51d
gh-81322: support multiple separators in StreamReader.readuntil (#16429) 2024-04-08 09:58:02 -07:00
Serhiy Storchaka 24a2bd0481
gh-117642: Fix PEP 737 implementation (GH-117643)
* Fix implementation of %#T and %#N (they were implemented as %T# and
  %N#).
* Restore tests removed in gh-116417.
2024-04-08 16:27:25 +00:00
Sam Gross 1a6594f661
gh-117439: Make refleak checking thread-safe without the GIL (#117469)
This keeps track of the per-thread total reference count operations in
PyThreadState in the free-threaded builds. The count is merged into the
interpreter's total when the thread exits.
2024-04-08 12:11:36 -04:00
Sam Gross 2067da2579
gh-117547: Fix mimalloc compile error on OpenBSD (#117548) 2024-04-08 11:53:13 -04:00
mpage df73179048
gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)
Most mutable data is protected by a striped lock that is keyed on the
referenced object's address. The weakref's hash is protected using the
weakref's per-object lock.
 
Note that this only affects free-threaded builds. Apart from some minor
refactoring, the added code is all either gated by `ifdef`s or is a no-op
(e.g. `Py_BEGIN_CRITICAL_SECTION`).
2024-04-08 10:58:38 -04:00
Laurie O e16062dd34
gh-96471: Correct documentation for asyncio queue shutdown (#117621) 2024-04-08 14:50:54 +00:00
Sam Gross 26a680a585
gh-117293: Fix race condition in run_workers.py (#117298)
The worker thread may still be alive after it enqueues it's last result,
which can lead to a delay of 30 seconds after the test finishes. This
happens much more frequently in the free-threaded build with the GIL
disabled.

This changes run_workers.py to track of live workers by enqueueing a
`WorkerExited()` instance before the worker exits.
2024-04-08 10:47:42 -04:00
Sam Gross 59864edd57
gh-117552: Add timeout in HTTPHandlerTest (#117553) 2024-04-08 10:46:56 -04:00
Erlend E. Aasland ca62ffd1a5
gh-116303: Skip tests if C recursion limit is unavailable (GH-117368)
The test suite fetches the C recursion limit from the _testcapi
extension module. Test extension modules can be disabled using the
--disable-test-modules configure option.
2024-04-08 14:45:25 +02:00
Victor Stinner 9a12f5d1c1
gh-106023: Update What's New in 3.13: _PyObject_FastCall() (#117633)
The function _PyObject_FastCall() was restored.
2024-04-08 12:19:43 +00:00
Nikita Sobolev a7702663e3
gh-111726: Explicitly close database connections in sqlite3 doctests (#111730)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2024-04-08 09:29:47 +00:00
Erlend E. Aasland e338e1a4ec
gh-111726: Remove some doctests from sqlite3 docs (#117623)
* remove load extension doctest since we cannot skip it conditionally
* remove sys.unraisablehook example; using unraisable hooks is not "an
  improved debug experience"
2024-04-08 08:11:08 +00:00
Victor Stinner e1eeb990bd
gh-113317: Remove unused INVALID constant in Argument Clinic (#117624) 2024-04-08 09:51:20 +02:00
Hugo van Kemenade a453f5ef9d
gh-111726: Cleanup test files after running sqlite3 doctest (#117604)
Remove all temporary databases in a dedicated 'testcleanup' step
at the end of the file.
2024-04-08 08:35:48 +02:00
Donghee Na 784623c63c
gh-117594: Require cpu resource to test_search_anchor_at_beginning (gh-117595) 2024-04-07 23:58:19 +00:00
Anita Hammer fd3679025d
Fix reference in code.rst (#117615)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-04-07 22:58:57 +00:00
Ken Jin 375425abd1
Cases generator: Remove type_prop and passthrough (#117614) 2024-04-08 06:26:52 +08:00
Nice Zombies 733e56ef96
gh-117584: Raise TypeError for non-paths in posixpath.relpath() (GH-117585) 2024-04-07 12:00:08 +03:00
Brandt Bucher 62aeb0ee69
GH-117512: Allow 64-bit JIT operands on 32-bit platforms (GH-117527) 2024-04-06 08:26:43 -07:00
Laurie O df4d84c3cd
gh-96471: Add asyncio queue shutdown (#104228)
Co-authored-by: Duprat <yduprat@gmail.com>
2024-04-06 07:27:13 -07:00
Malcolm Smith 1d3225ae05
gh-116622: Test updates for Android (#117299)
- re-enable test_fcntl_64_bit on Linux aarch64, but disable it on all
  Android ABIs
- use support.setswitchinterval in all relevant tests
- skip test_fma_zero_result on Android x86_64
- accept EACCES when calling os.get_terminal_size on Android
2024-04-05 20:57:36 +00:00
Barney Gale 6150bb2412
GH-77609: Add recurse_symlinks argument to `pathlib.Path.glob()` (#117311)
Replace tri-state `follow_symlinks` with boolean `recurse_symlinks` argument. The new argument controls whether symlinks are followed when expanding recursive `**` wildcards. The possible argument values correspond as follows:

    follow_symlinks  recurse_symlinks
    ===============  ================
    False            N/A
    None             False
    True             True

We therefore drop support for not following symlinks when expanding non-recursive pattern parts; it wasn't requested in the original issue, and it's a feature not found in any shells.

This makes the API a easier to grok by eliminating `None` as an option.

No news blurb as `follow_symlinks` was new in 3.13.
2024-04-05 18:51:54 +00:00