summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* gh-121110: Fix Extension Module Tests Under Py_TRACE_REFS Builds (gh-121503)Eric Snow2024-07-082-26/+43
| | | The change in gh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't. We fix that here. Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests.
* gh-121018: Fix typo in NEWS entry (#121510)Sam Gross2024-07-081-1/+1
|
* NEWS: Fix Sphinx warnings and increase threshold for new news nits (#121482)Hugo van Kemenade2024-07-0839-106/+110
| | | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-121404: remove direct accesses to u_private from codegen functions (#121500)Irit Katriel2024-07-081-27/+42
|
* gh-121368: Fix seq lock memory ordering in _PyType_Lookup (#121388)Sam Gross2024-07-089-16/+50
| | | | | | | | | The `_PySeqLock_EndRead` function needs an acquire fence to ensure that the load of the sequence happens after any loads within the read side critical section. The missing fence can trigger bugs on macOS arm64. Additionally, we need a release fence in `_PySeqLock_LockWrite` to ensure that the sequence update is visible before any modifications to the cache entry.
* gh-121487: Fix deprecation warning for ATOMIC_VAR_INIT in mimalloc (gh-121488)Marc Mueller2024-07-082-2/+7
|
* GH-119169: Simplify `os.walk()` exception handling (#121435)Barney Gale2024-07-082-50/+35
| | | | Handle errors from `os.scandir()` and `ScandirIterator` similarly, which lets us loop over directory entries with `for`.
* gh-121374: Correct docstrings in `_interpchannels` (gh-121418)Max Muoto2024-07-081-2/+2
|
* GH-121012: Set index to -1 when list iterators become exhausted in tier 2 ↵Mark Shannon2024-07-084-3/+20
| | | | (GH-121483)
* gh-121338: Remove #pragma optimize (#121340)Michael Droettboom2024-07-081-10/+0
|
* gh-108297: Update crashers README for test_crashers removal (#121475)Alyssa Coghlan2024-07-081-4/+0
| | | Update Lib/test/crashers/README for test_crashers removal
* gh-121461: Fix os.path.normpath documentation indentation (#121466)CBerJun2024-07-081-1/+1
|
* gh-121467: Fix makefile to include mimalloc headers (#121469)Marc Mueller2024-07-082-2/+3
|
* Fix sphinx reference target (#121470)Shantanu2024-07-081-2/+1
| | | | This was introduced in https://github.com/python/cpython/pull/121164 and appears to be causing test failures on main
* GH-73991: Fix "Operation not supported" on Fedora buildbot. (#121444)Barney Gale2024-07-071-4/+9
| | | | Follow-up to #120806. Use `os_helper.skip_unless_xattr` to skip testing xattr preservation when unsupported.
* Add Fidget-Spinner to stackrefs CODEOWNERS (GH-121455)Ken Jin2024-07-071-0/+1
|
* gh-121351: Skip test_not_wiping_history_file() if no readline (#121422)Sergey B Kirpichev2024-07-061-0/+4
|
* gh-119909: Fix ``NameError`` in ``asyncio`` REPL (#121341)Kirill Podoprigora2024-07-061-1/+1
|
* Regen ``Doc/requirements-oldest-sphinx.txt`` (#121437)Kirill Podoprigora2024-07-061-1/+1
| | | regen dependencies
* [docs] fix a Sphinx directive in `c-api/object.rst` (#121430)Bénédikt Tran2024-07-061-0/+1
|
* GH-73991: Support preserving metadata in `pathlib.Path.copy()` (#120806)Barney Gale2024-07-065-11/+187
| | | | | Add *preserve_metadata* keyword-only argument to `pathlib.Path.copy()`, defaulting to false. When set to true, we copy timestamps, permissions, extended attributes and flags where available, like `shutil.copystat()`. The argument has no effect on Windows, where metadata is always copied. Internally (in the pathlib ABCs), path types gain `_readable_metadata` and `_writable_metadata` attributes. These sets of strings describe what kinds of metadata can be retrieved and stored. We take an intersection of `source._readable_metadata` and `target._writable_metadata` to minimise reads/writes. A new `_read_metadata()` method accepts a set of metadata keys and returns a dict with those keys, and a new `_write_metadata()` method accepts a dict of metadata. We *might* make these public in future, but it's hard to justify while the ABCs are still private.
* gh-121359: Run test_pyrepl in isolated mode (#121414)Victor Stinner2024-07-051-1/+4
| | | | run_repl() now pass the -I option (isolated mode) to Python if the 'env' parameter is not set.
* Update example of str.split, bytes.split (#121287)Yuxin Wu2024-07-051-6/+10
| | | | | | | | | | | In `{str,bytes}.strip(chars)`, multiple characters are not treated as a prefix/suffix, but as individual characters. This may make users confuse whether `split` has similar behavior. Users may incorrectly expect that `'Good morning, John.'.split(', .') == ['Good', 'morning', 'John']` Adding a bit of clarification in the doc. Co-authored-by: Yuxin Wu <ppwwyyxx@users.noreply.github.com>
* gh-121288: Make error message for index() methods consistent (GH-121395)Serhiy Storchaka2024-07-055-5/+10
| | | | | | | | | Make error message for index() methods consistent Remove the repr of the searched value (which can be arbitrary large) from ValueError messages for list.index(), range.index(), deque.index(), deque.remove() and ShareableList.index(). Make the error messages consistent with error messages for other index() and remove() methods.
* Fixed regenerating files in a checkout path with spaces (GH-121384)AraHaan2024-07-051-9/+9
|
* gh-121149: improve accuracy of builtin sum() for complex inputs (gh-121176)Sergey B Kirpichev2024-07-054-26/+120
|
* gh-59110: Fix a debug output for implicit directories (GH-121375)Serhiy Storchaka2024-07-051-2/+4
|
* gh-121390: tracemalloc: Fix tracebacks memory leak (#121391)Josh Brobst2024-07-051-1/+1
| | | | | | The tracemalloc_tracebacks hash table has traceback keys and NULL values, but its destructors do not reflect this -- key_destroy_func is NULL while value_destroy_func is raw_free. Swap these to free the traceback keys instead.
* gh-90437: Fix __main__.py documentation wording (GH-116309)Ali Tavallaie2024-07-041-3/+3
| | | | Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Frank Dana <ferdnyc@gmail.com>
* gh-121084: Fix test_typing random leaks (#121360)Victor Stinner2024-07-042-0/+9
| | | | | Clear typing ABC caches when running tests for refleaks (-R option): call _abc_caches_clear() on typing abstract classes and their subclasses.
* gh-106597: Remove unnecessary CFrame offsets (#121369)Gabriele N. Tornetta2024-07-041-7/+0
|
* gh-59110: zipimport: support namespace packages when no directory entry ↵Serhiy Storchaka2024-07-044-30/+140
| | | | exists (GH-121233)
* gh-118507: Amend news entry to mention ntpath.isfile bugfix (GH-120817)Nice Zombies2024-07-041-0/+1
|
* gh-121272: move async for/with validation from compiler to symtable (#121361)Irit Katriel2024-07-042-13/+22
|
* gh-121355: Fix incorrect word in simple_stmts.rst (#121356)Jongbum Won2024-07-041-1/+1
|
* gh-120754: Update estimated_size in C truncate (#121357)Cody Maloney2024-07-041-0/+6
| | | | | | | | | | Sometimes a large file is truncated (test_largefile). While estimated_size is used as a estimate (the read will stil get the number of bytes in the file), that it is much larger than the actual size of data can result in a significant over allocation and sometimes lead to a MemoryError / running out of memory. This brings the C implementation to match the Python _pyio implementation.
* gh-121352: use _Py_SourceLocation in symtable (#121353)Irit Katriel2024-07-042-133/+69
|
* gh-120754: Reduce system calls in full-file FileIO.readall() case (#120755)Cody Maloney2024-07-043-33/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reduces the system call count of a simple program[0] that reads all the `.rst` files in Doc by over 10% (5706 -> 4734 system calls on my linux system, 5813 -> 4875 on my macOS) This reduces the number of `fstat()` calls always and seek calls most the time. Stat was always called twice, once at open (to error early on directories), and a second time to get the size of the file to be able to read the whole file in one read. Now the size is cached with the first call. The code keeps an optimization that if the user had previously read a lot of data, the current position is subtracted from the number of bytes to read. That is somewhat expensive so only do it on larger files, otherwise just try and read the extra bytes and resize the PyBytes as needeed. I built a little test program to validate the behavior + assumptions around relative costs and then ran it under `strace` to get a log of the system calls. Full samples below[1]. After the changes, this is everything in one `filename.read_text()`: ```python3 openat(AT_FDCWD, "cpython/Doc/howto/clinic.rst", O_RDONLY|O_CLOEXEC) = 3` fstat(3, {st_mode=S_IFREG|0644, st_size=343, ...}) = 0` ioctl(3, TCGETS, 0x7ffdfac04b40) = -1 ENOTTY (Inappropriate ioctl for device) lseek(3, 0, SEEK_CUR) = 0 read(3, ":orphan:\n\n.. This page is retain"..., 344) = 343 read(3, "", 1) = 0 close(3) = 0 ``` This does make some tradeoffs 1. If the file size changes between open() and readall(), this will still get all the data but might have more read calls. 2. I experimented with avoiding the stat + cached result for small files in general, but on my dev workstation at least that tended to reduce performance compared to using the fstat(). [0] ```python3 from pathlib import Path nlines = [] for filename in Path("cpython/Doc").glob("**/*.rst"): nlines.append(len(filename.read_text())) ``` [1] Before small file: ``` openat(AT_FDCWD, "cpython/Doc/howto/clinic.rst", O_RDONLY|O_CLOEXEC) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=343, ...}) = 0 ioctl(3, TCGETS, 0x7ffe52525930) = -1 ENOTTY (Inappropriate ioctl for device) lseek(3, 0, SEEK_CUR) = 0 lseek(3, 0, SEEK_CUR) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=343, ...}) = 0 read(3, ":orphan:\n\n.. This page is retain"..., 344) = 343 read(3, "", 1) = 0 close(3) = 0 ``` After small file: ``` openat(AT_FDCWD, "cpython/Doc/howto/clinic.rst", O_RDONLY|O_CLOEXEC) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=343, ...}) = 0 ioctl(3, TCGETS, 0x7ffdfac04b40) = -1 ENOTTY (Inappropriate ioctl for device) lseek(3, 0, SEEK_CUR) = 0 read(3, ":orphan:\n\n.. This page is retain"..., 344) = 343 read(3, "", 1) = 0 close(3) = 0 ``` Before large file: ``` openat(AT_FDCWD, "cpython/Doc/c-api/typeobj.rst", O_RDONLY|O_CLOEXEC) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=133104, ...}) = 0 ioctl(3, TCGETS, 0x7ffe52525930) = -1 ENOTTY (Inappropriate ioctl for device) lseek(3, 0, SEEK_CUR) = 0 lseek(3, 0, SEEK_CUR) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=133104, ...}) = 0 read(3, ".. highlight:: c\n\n.. _type-struc"..., 133105) = 133104 read(3, "", 1) = 0 close(3) = 0 ``` After large file: ``` openat(AT_FDCWD, "cpython/Doc/c-api/typeobj.rst", O_RDONLY|O_CLOEXEC) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=133104, ...}) = 0 ioctl(3, TCGETS, 0x7ffdfac04b40) = -1 ENOTTY (Inappropriate ioctl for device) lseek(3, 0, SEEK_CUR) = 0 lseek(3, 0, SEEK_CUR) = 0 read(3, ".. highlight:: c\n\n.. _type-struc"..., 133105) = 133104 read(3, "", 1) = 0 close(3) = 0 ``` Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-121141: add support for `copy.replace` to AST nodes (#121162)Bénédikt Tran2024-07-045-2/+837
|
* gh-117983: Defer import of threading for lazy module loading (#120233)Chris Markiewicz2024-07-032-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted in gh-117983, the import importlib.util can be triggered at interpreter startup under some circumstances, so adding threading makes it a potentially obligatory load. Lazy loading is not used in the stdlib, so this removes an unnecessary load for the majority of users and slightly increases the cost of the first lazily loaded module. An obligatory threading load breaks gevent, which monkeypatches the stdlib. Although unsupported, there doesn't seem to be an offsetting benefit to breaking their use case. For reference, here are benchmarks for the current main branch: ``` ❯ hyperfine -w 8 './python -c "import importlib.util"' Benchmark 1: ./python -c "import importlib.util" Time (mean ± σ): 9.7 ms ± 0.7 ms [User: 7.7 ms, System: 1.8 ms] Range (min … max): 8.4 ms … 13.1 ms 313 runs ``` And with this patch: ``` ❯ hyperfine -w 8 './python -c "import importlib.util"' Benchmark 1: ./python -c "import importlib.util" Time (mean ± σ): 8.4 ms ± 0.7 ms [User: 6.8 ms, System: 1.4 ms] Range (min … max): 7.2 ms … 11.7 ms 352 runs ``` Compare to: ``` ❯ hyperfine -w 8 './python -c pass' Benchmark 1: ./python -c pass Time (mean ± σ): 7.6 ms ± 0.6 ms [User: 5.9 ms, System: 1.6 ms] Range (min … max): 6.7 ms … 11.3 ms 390 runs ``` This roughly halves the import time of importlib.util.
* gh-118714: Make the pdb post-mortem restart/quit behavior more reasonable ↵Tian Gao2024-07-033-3/+25
| | | | (#118725)
* gh-112136: Restore removed _PyArg_Parser (#121262)Victor Stinner2024-07-038-24/+40
| | | | | | | Restore the private _PyArg_Parser structure and the private _PyArg_ParseTupleAndKeywordsFast() function, previously removed in Python 3.13 alpha 1. Recreate Include/cpython/modsupport.h header file.
* gh-121300: Add `replace` to `copy.__all__` (#121302)Max Muoto2024-07-032-3/+8
|
* gh-121201: Disable perf_trampoline on riscv64 for now (#121328)Stefano Rivera2024-07-034-5/+0
| | | | | | | Disable perf_trampoline on riscv64 for now Until support is added in perf_jit_trampoline.c gh-120089 was incomplete.
* GH-119726: Emit AArch64 trampolines out-of-line (GH-121280)Diego Russo2024-07-032-8/+8
|
* gh-121035: Update PNG image for logging flow diagram. (GH-121323)Vinay Sajip2024-07-031-0/+0
|
* gh-121245: a regression test for site.register_readline() (#121259)Sergey B Kirpichev2024-07-031-0/+27
|
* gh-121263: Macro-ify most stackref functions for MSVC (GH-121270)Ken Jin2024-07-031-58/+30
| | | Macro-ify most stackref functions for MSVC
* gh-121272: set ste_coroutine during symtable construction (#121297)Irit Katriel2024-07-032-3/+15
| | | compiler no longer modifies the symtable after this.
* gh-61103: Support float and long double complex types in ctypes module (#121248)Sergey B Kirpichev2024-07-0311-10/+135
| | | | | | | | | | | This amends 6988ff02a5: memory allocation for stginfo->ffi_type_pointer.elements in PyCSimpleType_init() should be more generic (perhaps someday fmt->pffi_type->elements will be not a two-elements array). It should finally resolve #61103. Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>