]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
16 months agogh-121390: tracemalloc: Fix tracebacks memory leak (#121391)
Josh Brobst [Fri, 5 Jul 2024 06:39:48 +0000 (02:39 -0400)] 
gh-121390: tracemalloc: Fix tracebacks memory leak (#121391)

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.

16 months agogh-90437: Fix __main__.py documentation wording (GH-116309)
Ali Tavallaie [Thu, 4 Jul 2024 22:49:14 +0000 (02:19 +0330)] 
gh-90437: Fix __main__.py documentation wording (GH-116309)

Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Frank Dana <ferdnyc@gmail.com>
16 months agogh-121084: Fix test_typing random leaks (#121360)
Victor Stinner [Thu, 4 Jul 2024 17:38:30 +0000 (19:38 +0200)] 
gh-121084: Fix test_typing random leaks (#121360)

Clear typing ABC caches when running tests for refleaks (-R option):
call _abc_caches_clear() on typing abstract classes and their
subclasses.

16 months agogh-106597: Remove unnecessary CFrame offsets (#121369)
Gabriele N. Tornetta [Thu, 4 Jul 2024 17:28:23 +0000 (18:28 +0100)] 
gh-106597: Remove unnecessary CFrame offsets (#121369)

16 months agogh-59110: zipimport: support namespace packages when no directory entry exists (GH...
Serhiy Storchaka [Thu, 4 Jul 2024 15:04:24 +0000 (18:04 +0300)] 
gh-59110: zipimport: support namespace packages when no directory entry exists (GH-121233)

16 months agogh-118507: Amend news entry to mention ntpath.isfile bugfix (GH-120817)
Nice Zombies [Thu, 4 Jul 2024 14:56:06 +0000 (16:56 +0200)] 
gh-118507: Amend news entry to mention ntpath.isfile bugfix (GH-120817)

16 months agogh-121272: move async for/with validation from compiler to symtable (#121361)
Irit Katriel [Thu, 4 Jul 2024 13:47:21 +0000 (14:47 +0100)] 
gh-121272: move async for/with validation from compiler to symtable (#121361)

16 months agogh-121355: Fix incorrect word in simple_stmts.rst (#121356)
Jongbum Won [Thu, 4 Jul 2024 13:34:34 +0000 (22:34 +0900)] 
gh-121355: Fix incorrect word in simple_stmts.rst (#121356)

16 months agogh-120754: Update estimated_size in C truncate (#121357)
Cody Maloney [Thu, 4 Jul 2024 12:59:18 +0000 (05:59 -0700)] 
gh-120754: Update estimated_size in C truncate (#121357)

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.

16 months agogh-121352: use _Py_SourceLocation in symtable (#121353)
Irit Katriel [Thu, 4 Jul 2024 10:28:44 +0000 (11:28 +0100)] 
gh-121352: use _Py_SourceLocation in symtable (#121353)

16 months agogh-120754: Reduce system calls in full-file FileIO.readall() case (#120755)
Cody Maloney [Thu, 4 Jul 2024 07:17:00 +0000 (00:17 -0700)] 
gh-120754: Reduce system calls in full-file FileIO.readall() case (#120755)

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>
16 months agogh-121141: add support for `copy.replace` to AST nodes (#121162)
Bénédikt Tran [Thu, 4 Jul 2024 03:10:54 +0000 (05:10 +0200)] 
gh-121141: add support for `copy.replace` to AST nodes (#121162)

16 months agogh-117983: Defer import of threading for lazy module loading (#120233)
Chris Markiewicz [Wed, 3 Jul 2024 20:50:46 +0000 (16:50 -0400)] 
gh-117983: Defer import of threading for lazy module loading (#120233)

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.

16 months agogh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (#118725)
Tian Gao [Wed, 3 Jul 2024 18:30:20 +0000 (11:30 -0700)] 
gh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (#118725)

16 months agogh-112136: Restore removed _PyArg_Parser (#121262)
Victor Stinner [Wed, 3 Jul 2024 16:36:57 +0000 (18:36 +0200)] 
gh-112136: Restore removed _PyArg_Parser (#121262)

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.

16 months agogh-121300: Add `replace` to `copy.__all__` (#121302)
Max Muoto [Wed, 3 Jul 2024 15:03:56 +0000 (10:03 -0500)] 
gh-121300: Add `replace` to `copy.__all__` (#121302)

16 months agogh-121201: Disable perf_trampoline on riscv64 for now (#121328)
Stefano Rivera [Wed, 3 Jul 2024 14:44:34 +0000 (07:44 -0700)] 
gh-121201: Disable perf_trampoline on riscv64 for now (#121328)

Disable perf_trampoline on riscv64 for now

Until support is added in perf_jit_trampoline.c

gh-120089 was incomplete.

16 months agoGH-119726: Emit AArch64 trampolines out-of-line (GH-121280)
Diego Russo [Wed, 3 Jul 2024 13:22:21 +0000 (14:22 +0100)] 
GH-119726: Emit AArch64 trampolines out-of-line (GH-121280)

16 months agogh-121035: Update PNG image for logging flow diagram. (GH-121323)
Vinay Sajip [Wed, 3 Jul 2024 11:33:28 +0000 (12:33 +0100)] 
gh-121035: Update PNG image for logging flow diagram. (GH-121323)

16 months agogh-121245: a regression test for site.register_readline() (#121259)
Sergey B Kirpichev [Wed, 3 Jul 2024 10:45:43 +0000 (13:45 +0300)] 
gh-121245: a regression test for site.register_readline() (#121259)

16 months agogh-121263: Macro-ify most stackref functions for MSVC (GH-121270)
Ken Jin [Wed, 3 Jul 2024 09:49:31 +0000 (17:49 +0800)] 
gh-121263: Macro-ify most stackref functions for MSVC (GH-121270)

Macro-ify most stackref functions for MSVC

16 months agogh-121272: set ste_coroutine during symtable construction (#121297)
Irit Katriel [Wed, 3 Jul 2024 09:18:34 +0000 (10:18 +0100)] 
gh-121272: set ste_coroutine during symtable construction (#121297)

compiler no longer modifies the symtable after this.

16 months agogh-61103: Support float and long double complex types in ctypes module (#121248)
Sergey B Kirpichev [Wed, 3 Jul 2024 09:08:11 +0000 (12:08 +0300)] 
gh-61103: Support float and long double complex types in ctypes module (#121248)

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>
16 months agogh-106597: Add more offsets to _Py_DebugOffsets (#121311)
Gabriele N. Tornetta [Wed, 3 Jul 2024 08:53:44 +0000 (09:53 +0100)] 
gh-106597: Add more offsets to _Py_DebugOffsets (#121311)

Add more offsets to _Py_DebugOffsets

We add a few more offsets that are required by some out-of-process
tools, such as [Austin](https://github.com/p403n1x87/austin).

16 months agoDocs: Add `os.splice` flags argument (#109847)
Amin Alaee [Wed, 3 Jul 2024 08:10:57 +0000 (10:10 +0200)] 
Docs: Add `os.splice` flags argument (#109847)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Blaise Pabon <blaise@gmail.com>
16 months agodocs: Fix "Py_TPFLAGS_MANAGED_WEAKREF is set in tp_flags" (#112237)
da-woods [Wed, 3 Jul 2024 08:05:02 +0000 (09:05 +0100)] 
docs: Fix "Py_TPFLAGS_MANAGED_WEAKREF is set in tp_flags" (#112237)

16 months agobuild(deps): bump hypothesis from 6.100.2 to 6.104.2 in /Tools (#121218)
dependabot[bot] [Wed, 3 Jul 2024 07:52:59 +0000 (13:22 +0530)] 
build(deps): bump hypothesis from 6.100.2 to 6.104.2 in /Tools (#121218)

Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.100.2 to 6.104.2.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.100.2...hypothesis-python-6.104.2)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
16 months agoupdated tp_flags initialization to use inplace or (#120625)
byundojin [Wed, 3 Jul 2024 07:51:25 +0000 (16:51 +0900)] 
updated tp_flags initialization to use inplace or (#120625)

16 months agogh-111872: Document the max_children attribute for `socketserver.ForkingMixIn` (...
AN Long [Wed, 3 Jul 2024 07:46:57 +0000 (15:46 +0800)] 
gh-111872: Document the max_children attribute for `socketserver.ForkingMixIn` (#118134)

16 months agogh-116181: Remove Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE in rotatingtree...
AN Long [Wed, 3 Jul 2024 07:35:05 +0000 (15:35 +0800)] 
gh-116181: Remove Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE in rotatingtree.c (#121260)

16 months agogh-121027: Make the functools.partial object a method descriptor (GH-121089)
Serhiy Storchaka [Wed, 3 Jul 2024 06:02:15 +0000 (09:02 +0300)] 
gh-121027: Make the functools.partial object a method descriptor (GH-121089)

Co-authored-by: d.grigonis <dgrigonis@users.noreply.github.com>
16 months agoGH-73991: Support copying directory symlinks on older Windows (#120807)
Barney Gale [Wed, 3 Jul 2024 03:30:29 +0000 (04:30 +0100)] 
GH-73991: Support copying directory symlinks on older Windows (#120807)

Check for `ERROR_INVALID_PARAMETER` when calling `_winapi.CopyFile2()` and
raise `UnsupportedOperation`. In `Path.copy()`, handle this exception and
fall back to the `PathBase.copy()` implementation.

16 months agogh-121035: Further improve logging flow diagram with respect to dark/light modes...
Vinay Sajip [Tue, 2 Jul 2024 17:57:34 +0000 (18:57 +0100)] 
gh-121035: Further improve logging flow diagram with respect to dark/light modes. (GH-121265)

16 months agogh-115773: Add sizes to debug offset structure (#120112)
Pablo Galindo Salgado [Tue, 2 Jul 2024 17:54:33 +0000 (18:54 +0100)] 
gh-115773: Add sizes to debug offset structure (#120112)

16 months agogh-117139: Add _PyTuple_FromStackRefSteal and use it (#121244)
Sam Gross [Tue, 2 Jul 2024 16:30:14 +0000 (12:30 -0400)] 
gh-117139: Add _PyTuple_FromStackRefSteal and use it (#121244)

Avoids the extra conversion from stack refs to PyObjects.

16 months agogh-121272: move __future__ import validation from compiler to symtable (#121273)
Irit Katriel [Tue, 2 Jul 2024 16:22:08 +0000 (17:22 +0100)] 
gh-121272: move __future__ import validation from compiler to symtable (#121273)

16 months agogh-121165: protect macro expansion of `ADJUST_INDICES` with do-while(0) (#121166)
Bénédikt Tran [Tue, 2 Jul 2024 10:57:51 +0000 (12:57 +0200)] 
gh-121165: protect macro expansion of `ADJUST_INDICES` with do-while(0) (#121166)

16 months agogh-121210: handle nodes with missing attributes/fields in `ast.compare` (#121211)
Bénédikt Tran [Tue, 2 Jul 2024 10:53:17 +0000 (12:53 +0200)] 
gh-121210: handle nodes with missing attributes/fields in `ast.compare` (#121211)

16 months agogh-121245: Amend d611c4c8e9 (correct import) (#121255)
Sergey B Kirpichev [Tue, 2 Jul 2024 09:40:01 +0000 (12:40 +0300)] 
gh-121245: Amend d611c4c8e9 (correct import) (#121255)

Co-authored-by: Miro Hrončok <miro@hroncok.cz>
16 months agoMove get_signal_name() to test.support (#121251)
Victor Stinner [Tue, 2 Jul 2024 08:34:13 +0000 (10:34 +0200)] 
Move get_signal_name() to test.support (#121251)

* Move get_signal_name() from test.libregrtest to test.support.
* Use get_signal_name() in support.script_helper.
* support.script_helper now decodes stdout and stderr from UTF-8,
  instead of ASCII, if a command failed.

16 months agogh-121035: Improve logging flow diagram for dark/light modes. (GH-121254)
Vinay Sajip [Tue, 2 Jul 2024 08:13:37 +0000 (09:13 +0100)] 
gh-121035: Improve logging flow diagram for dark/light modes. (GH-121254)

16 months agoFix phrasing in paragraphs with leading "similar" (#121135)
Rafael Fontenelle [Tue, 2 Jul 2024 00:36:27 +0000 (21:36 -0300)] 
Fix phrasing in paragraphs with leading "similar" (#121135)

16 months agoGH-119726: Use LDR for AArch64 trampolines (GH-121001)
Diego Russo [Mon, 1 Jul 2024 22:52:33 +0000 (23:52 +0100)] 
GH-119726: Use LDR for AArch64 trampolines (GH-121001)

16 months agogh-121196: Document `dict.fromkeys` params as pos-only (#121197)
sobolevn [Mon, 1 Jul 2024 20:27:04 +0000 (23:27 +0300)] 
gh-121196: Document `dict.fromkeys` params as pos-only (#121197)

16 months agoGH-116017: Get rid of _COLD_EXITs (GH-120960)
Brandt Bucher [Mon, 1 Jul 2024 20:17:40 +0000 (13:17 -0700)] 
GH-116017: Get rid of _COLD_EXITs (GH-120960)

16 months agogh-117657: Fix data races reported by TSAN in some set methods (#120914)
AN Long [Mon, 1 Jul 2024 19:11:39 +0000 (03:11 +0800)] 
gh-117657: Fix data races reported by TSAN in some set methods (#120914)

Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed
atomic loads in the free-threaded build.

After this change, the TSAN doesn't report data races for this method.

16 months agogh-121110: Temporarily Skip test_basic_multiple_interpreters_reset_each (gh-121236)
Eric Snow [Mon, 1 Jul 2024 17:58:25 +0000 (11:58 -0600)] 
gh-121110: Temporarily Skip test_basic_multiple_interpreters_reset_each (gh-121236)

This will allow Py_TRACE_REFS builds to pass the test suite, until the underlying issue can be resolved.

16 months agogh-114104: clarify asynchronous comprehension docs to match runtime behavior (#121175)
Danny Yang [Mon, 1 Jul 2024 16:34:39 +0000 (12:34 -0400)] 
gh-114104: clarify asynchronous comprehension docs to match runtime behavior (#121175)

16 months agogh-120743: Soft deprecate os.popen() function (#120744)
Victor Stinner [Mon, 1 Jul 2024 16:27:50 +0000 (18:27 +0200)] 
gh-120743: Soft deprecate os.popen() function (#120744)

Soft deprecate os.popen() and os.spawn*() functions.

16 months agogh-121200: Fix test_expanduser_pwd2() of test_posixpath (#121228)
Victor Stinner [Mon, 1 Jul 2024 15:49:03 +0000 (17:49 +0200)] 
gh-121200: Fix test_expanduser_pwd2() of test_posixpath (#121228)

Call getpwnam() to get pw_dir, since it can be different than
getpwall() pw_dir.

16 months agogh-117657: Use critical section to make _socket.socket.close thread safe (GH-120490)
AN Long [Mon, 1 Jul 2024 14:38:30 +0000 (22:38 +0800)] 
gh-117657: Use critical section to make _socket.socket.close thread safe (GH-120490)

16 months agogh-121220: Mark test_threaded_weak_value_dict_copy() as CPU-heavy (#121221)
Kirill Podoprigora [Mon, 1 Jul 2024 13:33:02 +0000 (16:33 +0300)] 
gh-121220: Mark test_threaded_weak_value_dict_copy() as CPU-heavy (#121221)

Mark test_threaded_weak_value_dict_copy() and
test_threaded_weak_key_dict_copy() of test_weakref as
CPU-heavy tests

16 months agogh-117784: Only reference PHA functions ifndef SSL_VERIFY_POST_HANDSHAKE (GH-117785)
Will Childs-Klein [Mon, 1 Jul 2024 13:28:35 +0000 (09:28 -0400)] 
gh-117784: Only reference PHA functions ifndef SSL_VERIFY_POST_HANDSHAKE (GH-117785)

With this change, builds with OpenSSL forks that don't have this functionalty
(like AWS-LC or BoringSSL) will require less patching.

16 months agobuild(deps-dev): bump types-setuptools from 70.0.0.20240524 to 70.1.0.20240627 in...
dependabot[bot] [Mon, 1 Jul 2024 10:42:46 +0000 (10:42 +0000)] 
build(deps-dev): bump types-setuptools from 70.0.0.20240524 to 70.1.0.20240627 in /Tools (#121217)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
16 months agobuild(deps-dev): bump mypy from 1.10.0 to 1.10.1 in /Tools (#121216)
dependabot[bot] [Mon, 1 Jul 2024 10:15:53 +0000 (10:15 +0000)] 
build(deps-dev): bump mypy from 1.10.0 to 1.10.1 in /Tools (#121216)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
16 months agobuild(deps-dev): bump types-psutil from 5.9.5.20240516 to 6.0.0.20240621 in /Tools...
dependabot[bot] [Mon, 1 Jul 2024 10:15:25 +0000 (10:15 +0000)] 
build(deps-dev): bump types-psutil from 5.9.5.20240516 to 6.0.0.20240621 in /Tools (#121215)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
16 months agogh-121200: Log pwd entry in test_expanduser_pwd2() (#121207)
Victor Stinner [Mon, 1 Jul 2024 09:43:59 +0000 (11:43 +0200)] 
gh-121200: Log pwd entry in test_expanduser_pwd2() (#121207)

Use subTest() to log the pwd entry in test_expanduser_pwd2() of
test_posixpath to help debugging.

16 months agogh-121084: Call _abc_registry_clear() when checking refleaks (#121191)
Victor Stinner [Mon, 1 Jul 2024 09:03:33 +0000 (11:03 +0200)] 
gh-121084: Call _abc_registry_clear() when checking refleaks (#121191)

dash_R_cleanup() now calls _abc_registry_clear() before calling again
register().

16 months agogh-61103: Support double complex (_Complex) type in ctypes (#120894)
Sergey B Kirpichev [Mon, 1 Jul 2024 08:54:33 +0000 (11:54 +0300)] 
gh-61103: Support double complex (_Complex) type in ctypes (#120894)

Example:

```pycon
>>> import ctypes
>>> ctypes.__STDC_IEC_559_COMPLEX__
1
>>> libm = ctypes.CDLL('libm.so.6')
>>> libm.clog.argtypes = [ctypes.c_double_complex]
>>> libm.clog.restype = ctypes.c_double_complex
>>> libm.clog(1+1j)
(0.34657359027997264+0.7853981633974483j)
```

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
16 months agogh-121199: Use _Py__has_attribute() in timemodule.c (#121203)
Victor Stinner [Mon, 1 Jul 2024 08:49:33 +0000 (10:49 +0200)] 
gh-121199: Use _Py__has_attribute() in timemodule.c (#121203)

Use the _Py__has_attribute() macro in timemodule.c and
bootstrap_hash.c to fix a build error on old GCC versions (GCC 4.8.5
on s390x).

16 months agogh-121188: Sanitize invalid XML characters in regrtest (#121195)
Victor Stinner [Mon, 1 Jul 2024 08:30:33 +0000 (10:30 +0200)] 
gh-121188: Sanitize invalid XML characters in regrtest (#121195)

When creating the JUnit XML file, regrtest now escapes characters
which are invalid in XML, such as the chr(27) control character used
in ANSI escape sequences.

16 months agogh-113565: Improve and harden detection of curses dependencies (#119816)
Erlend E. Aasland [Mon, 1 Jul 2024 08:10:03 +0000 (10:10 +0200)] 
gh-113565: Improve and harden detection of curses dependencies (#119816)

1. Use pkg-config to check for ncursesw/panelw. If that fails, use
   pkg-config to check for ncurses/panel.
2. Regardless of pkg-config output, search for curses/panel headers, so
   we're sure we have all defines in pyconfig.h.
3. Regardless of pkg-config output, check if libncurses or libncursesw
   contains the 'initscr' symbol; if it does _and_ pkg-config failed
   earlier, add the resulting -llib linker option to CURSES_LIBS.
   Ditto for 'update_panels' and PANEL_LIBS.
4. Wrap the rest of the checks with WITH_SAVE_ENV and make sure we're
   using updated LIBS and CPPFLAGS for those.

Add the PY_CHECK_CURSES convenience macro.

16 months agogh-87744: fix waitpid race while calling send_signal in asyncio (#121126)
Kumar Aditya [Mon, 1 Jul 2024 04:47:36 +0000 (10:17 +0530)] 
gh-87744: fix waitpid race while calling send_signal in asyncio (#121126)

asyncio earlier relied on subprocess module to send signals to the process, this has some drawbacks one being that subprocess module unnecessarily calls waitpid on child processes and hence it races with asyncio implementation which internally uses child watchers. To mitigate this, now asyncio sends signals directly to the process without going through the subprocess on non windows systems. On Windows it fallbacks to subprocess module handling but on windows there are no child watchers so this issue doesn't exists altogether.

16 months agogh-121163: Add "all" as an valid alias for "always" in warnings.simplefilter() (...
Kirill Podoprigora [Sun, 30 Jun 2024 17:48:00 +0000 (20:48 +0300)] 
gh-121163: Add "all" as an valid alias for "always" in warnings.simplefilter() (#121164)

Add support for ``all`` as an valid alias for ``always`` in ``warnings.simplefilter()``
and ``warnings.filterswarnings()``.

16 months ago[doc] Update element positions and styles in logging flow diagram. (GH-121182)
Vinay Sajip [Sun, 30 Jun 2024 13:38:49 +0000 (14:38 +0100)] 
[doc] Update element positions and styles in logging flow diagram. (GH-121182)

Update element positions and styles.

16 months agogh-119447: Fix build with _PY_SHORT_FLOAT_REPR == 0 (#121178)
Yureka [Sun, 30 Jun 2024 09:40:40 +0000 (11:40 +0200)] 
gh-119447: Fix build with _PY_SHORT_FLOAT_REPR == 0 (#121178)

16 months agogh-120522: Add a `--with-app-store-compliance` configure option to patch out problema...
Russell Keith-Magee [Sun, 30 Jun 2024 00:34:35 +0000 (08:34 +0800)] 
gh-120522: Add a `--with-app-store-compliance` configure option to patch out problematic code (#120984)

* Add --app-store-compliance configuration option.

* Added blurb.

* Correct tab-vs-spaces formatting issue.

* Correct source file name in docs.

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
* Correct source code reference in Mac docs

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
* Only apply the patch forward, and ensure the working directory is correct.

* Make patching reslient to multiple builds.

* Documentation fixes found during review

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
* Documentation and configure.ac syntax improvements

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* Regenerate configure script.

* Silence the patch echo output.

---------

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
16 months agoGH-119054: Add alt text to pathlib inheritance diagram (#121158)
Barney Gale [Sat, 29 Jun 2024 17:46:53 +0000 (18:46 +0100)] 
GH-119054: Add alt text to pathlib inheritance diagram (#121158)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
16 months agoGH-119054: Add "Expanding and resolving paths" section to pathlib docs. (#120970)
Barney Gale [Sat, 29 Jun 2024 15:09:47 +0000 (16:09 +0100)] 
GH-119054: Add "Expanding and resolving paths" section to pathlib docs. (#120970)

Add dedicated subsection for `home()`, `expanduser()`, `cwd()`,
`absolute()`, `resolve()` and `readlink()`. The position of this section
keeps all the `Path` constructors (`Path()`, `Path.from_uri()`,
`Path.home()` and `Path.cwd()`) near the top. Within the section, closely
related methods are kept adjacent. Specifically:

-.`home()` and `expanduser()` (the former calls the latter)
- `cwd()` and `absolute()` (the former calls the latter)
- `absolute()` and `resolve()` (both make paths absolute)
- `resolve()` and `readlink()` (both read symlink targets)
- Ditto `cwd()` and `absolute()`
- Ditto `absolute()` and `resolve()`

The "Other methods" section is removed.

16 months agogh-119372: Recover inf's and zeros in _Py_c_quot (GH-119457)
Sergey B Kirpichev [Sat, 29 Jun 2024 08:00:48 +0000 (11:00 +0300)] 
gh-119372: Recover inf's and zeros in _Py_c_quot (GH-119457)

In some cases, previously computed as (nan+nanj), we could
recover meaningful component values in the result, see
e.g. the C11, Annex G.5.2, routine _Cdivd().

16 months agogh-121101: Document -Wall option (an alias for -Walways) (#121102)
Wim Jeantine-Glenn [Sat, 29 Jun 2024 06:40:13 +0000 (01:40 -0500)] 
gh-121101: Document -Wall option (an alias for -Walways) (#121102)

16 months agogh-120713: Normalize year with century for datetime.strftime (GH-120820)
blhsing [Sat, 29 Jun 2024 06:32:42 +0000 (14:32 +0800)] 
gh-120713: Normalize year with century for datetime.strftime (GH-120820)

16 months agogh-121137: Add missing Py_DECREF calls for ADDITEMS opcode of _pickle.c (#121136)
Justin Applegate [Fri, 28 Jun 2024 21:43:45 +0000 (15:43 -0600)] 
gh-121137: Add missing Py_DECREF calls for ADDITEMS opcode of _pickle.c (#121136)

PyObject_GetAttr returns a new reference, but this reference is never decremented using Py_DECREF, so Py_DECREF calls to this referece are added

16 months agogh-117139: Fix a few wrong steals in bytecodes.c (GH-121127)
Ken Jin [Fri, 28 Jun 2024 18:14:48 +0000 (02:14 +0800)] 
gh-117139: Fix a few wrong steals in bytecodes.c (GH-121127)

Fix a few wrong steals in bytecodes.c

16 months agogh-121115: Skip __index__ in PyLong_AsNativeBytes by default (GH-121118)
Steve Dower [Fri, 28 Jun 2024 15:26:21 +0000 (16:26 +0100)] 
gh-121115: Skip __index__ in PyLong_AsNativeBytes by default (GH-121118)

16 months agogh-121018: Fix more cases of exiting in argparse when exit_on_error=False (GH-121056)
Serhiy Storchaka [Fri, 28 Jun 2024 14:21:59 +0000 (17:21 +0300)] 
gh-121018: Fix more cases of exiting in argparse when exit_on_error=False (GH-121056)

* parse_intermixed_args() now raises ArgumentError instead of calling
  error() if exit_on_error is false.
* Internal code now always raises ArgumentError instead of calling
  error(). It is then caught at the higher level and error() is called if
  exit_on_error is true.

16 months agoCheck for compiler warnings in test_cext on Windows (#121088)
Victor Stinner [Fri, 28 Jun 2024 12:41:37 +0000 (14:41 +0200)] 
Check for compiler warnings in test_cext on Windows (#121088)

On Windows, test_cext and test_cppext now pass /WX flag to the MSC
compiler to treat all compiler warnings as errors. In verbose mode,
these tests now log the compiler commands to help debugging.

Change Py_BUILD_ASSERT_EXPR implementation on Windows to avoid a
compiler warning about an unnamed structure.

16 months agogh-120804: remove `is_active` method from internal child watchers implementation...
Kumar Aditya [Fri, 28 Jun 2024 11:53:56 +0000 (17:23 +0530)] 
gh-120804: remove `is_active` method from internal child watchers implementation in asyncio (#121124)

16 months agogh-121096: Ignore dlopen() leaks in Valgrind suppression file (#121097)
Victor Stinner [Fri, 28 Jun 2024 11:10:11 +0000 (13:10 +0200)] 
gh-121096: Ignore dlopen() leaks in Valgrind suppression file (#121097)

16 months agogh-107803: add whatsnew for asyncio double linked list implementation (#120995)
Kumar Aditya [Fri, 28 Jun 2024 09:03:31 +0000 (14:33 +0530)] 
gh-107803: add whatsnew for asyncio double linked list implementation (#120995)

16 months agogh-120837: Update _Py_DumpExtensionModules to be async-signal-safe (gh-121051)
Donghee Na [Thu, 27 Jun 2024 21:46:46 +0000 (06:46 +0900)] 
gh-120837: Update _Py_DumpExtensionModules to be async-signal-safe (gh-121051)

16 months agogh-121035: Update logging flow chart to include the lastResort handler. (GH-121036)
Alexander Bessman [Thu, 27 Jun 2024 21:11:40 +0000 (23:11 +0200)] 
gh-121035: Update logging flow chart to include the lastResort handler. (GH-121036)

16 months agogh-121065: Temporarily skip flaky test on free-threaded build (#121100)
Sam Gross [Thu, 27 Jun 2024 18:03:09 +0000 (14:03 -0400)] 
gh-121065: Temporarily skip flaky test on free-threaded build (#121100)

16 months agogh-105623 Fix performance degradation in logging RotatingFileHandler (GH-105887)
Craig Robson [Thu, 27 Jun 2024 16:44:40 +0000 (09:44 -0700)] 
gh-105623 Fix performance degradation in logging RotatingFileHandler (GH-105887)

The check for whether the log file is a real file is expensive on NFS
filesystems.  This commit reorders the rollover condition checking to
not do the file type check if the expected file size is less than the
rotation threshold.

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
16 months agogh-115986 Improve pprint docs formatting (GH-117401)
Kerim Kabirov [Thu, 27 Jun 2024 14:32:50 +0000 (16:32 +0200)] 
gh-115986 Improve pprint docs formatting (GH-117401)

* Move pprinter parameters description to the table

The change improves readability.
Suggested in the GH#116085 PR discussion.

* Make pprint doc with params markup

* Fix formatting
Indentation of code blocks made them nested
"Version changed" is better placed after the code block

* Fix formatting for tests

* fix code indentation for autotests

* Fix identation for autotests

* Remove duplication of the parameters' description

* Rearrange parameters description in a correct order

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
16 months agogh-121027: Add a future warning in functools.partial.__get__ (#121086)
Serhiy Storchaka [Thu, 27 Jun 2024 11:47:20 +0000 (14:47 +0300)] 
gh-121027: Add a future warning in functools.partial.__get__ (#121086)

16 months agogh-121082: Fix build failure when the developer use `--enable-pystats` arguments...
Nadeshiko Manju [Thu, 27 Jun 2024 11:35:25 +0000 (19:35 +0800)] 
gh-121082: Fix build failure when the developer use `--enable-pystats` arguments in configuration command after #118450 (#121083)

Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
16 months agogh-120593: Check -Wcast-qual flag in test_cext (#121081)
Victor Stinner [Thu, 27 Jun 2024 10:22:48 +0000 (12:22 +0200)] 
gh-120593: Check -Wcast-qual flag in test_cext (#121081)

Check the usage of the 'const' qualifier in the Python C API in
test_cext.

16 months agogh-120686: remove unused internal c api functions (#120687)
Irit Katriel [Thu, 27 Jun 2024 10:09:30 +0000 (11:09 +0100)] 
gh-120686: remove unused internal c api functions (#120687)

16 months agogh-121040: Use __attribute__((fallthrough)) (#121044)
Victor Stinner [Thu, 27 Jun 2024 09:58:44 +0000 (11:58 +0200)] 
gh-121040: Use __attribute__((fallthrough)) (#121044)

Fix warnings when using -Wimplicit-fallthrough compiler flag.

Annotate explicitly "fall through" switch cases with a new
_Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if
available. Replace "fall through" comments with _Py_FALLTHROUGH.

Add _Py__has_attribute() macro. No longer define __has_attribute()
macro if it's not defined. Move also _Py__has_builtin() at the top
of pyport.h.

Co-Authored-By: Nikita Sobolev <mail@sobolevn.me>
16 months agogh-120888: Bump bundled pip to 24.1.1 (#120889)
Pradyun Gedam [Thu, 27 Jun 2024 09:09:54 +0000 (10:09 +0100)] 
gh-120888: Bump bundled pip to 24.1.1 (#120889)

Co-authored-by: Pradyun Gedam <pradyunsg@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
16 months agogh-119521: Remove _IncompleteInputError from the docs (GH-120993)
Petr Viktorin [Thu, 27 Jun 2024 07:09:22 +0000 (09:09 +0200)] 
gh-119521: Remove _IncompleteInputError from the docs (GH-120993)

16 months agogh-120868: Fix breaking change in `logging.config` when using `QueueHandler` (GH...
Janek Nouvertné [Thu, 27 Jun 2024 07:09:01 +0000 (09:09 +0200)] 
gh-120868: Fix breaking change in `logging.config` when using `QueueHandler` (GH-120872)

16 months agogh-113433: Automatically Clean Up Subinterpreters in Py_Finalize() (gh-121060)
Eric Snow [Wed, 26 Jun 2024 21:17:26 +0000 (15:17 -0600)] 
gh-113433: Automatically Clean Up Subinterpreters in Py_Finalize() (gh-121060)

This change makes things a little less painful for some users.  It also fixes a failing assert (gh-120765), by making sure all subinterpreters are destroyed before the main interpreter.  As part of that, we make sure Py_Finalize() always runs with the main interpreter active.

16 months agogh-120937: Reference weakref from the `__del__` documentation (#120940)
chaen [Wed, 26 Jun 2024 20:07:09 +0000 (22:07 +0200)] 
gh-120937: Reference weakref from the `__del__` documentation (#120940)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
16 months agogh-117139: Convert the evaluation stack to stack refs (#118450)
Ken Jin [Wed, 26 Jun 2024 19:10:43 +0000 (03:10 +0800)] 
gh-117139: Convert the evaluation stack to stack refs (#118450)

This PR sets up tagged pointers for CPython.

The general idea is to create a separate struct _PyStackRef for everything on the evaluation stack to store the bits. This forces the C compiler to warn us if we try to cast things or pull things out of the struct directly.

Only for free threading: We tag the low bit if something is deferred - that means we skip incref and decref operations on it. This behavior may change in the future if Mark's plans to defer all objects in the interpreter loop pans out.

This implies a strict stack reference discipline is required. ALL incref and decref operations on stackrefs must use the stackref variants. It is unsafe to untag something then do normal incref/decref ops on it.

The new incref and decref variants are called dup and close. They mimic a "handle" API operating on these stackrefs.

Please read Include/internal/pycore_stackref.h for more information!

---------

Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
16 months agogh-118908: Use __main__ for the default PyREPL namespace (#121054)
Łukasz Langa [Wed, 26 Jun 2024 19:01:10 +0000 (15:01 -0400)] 
gh-118908: Use __main__ for the default PyREPL namespace (#121054)

16 months agogh-120593: Fix const qualifier in _PyLong_CompactValue() (#121053)
Victor Stinner [Wed, 26 Jun 2024 18:11:21 +0000 (20:11 +0200)] 
gh-120593: Fix const qualifier in _PyLong_CompactValue() (#121053)

Remove the const qualifier of the argument of functions:

* _PyLong_IsCompact()
* _PyLong_CompactValue()

Py_TYPE() argument is not const.

Fix the compiler warning:

  Include/cpython/longintrepr.h: In function ‘_PyLong_CompactValue’:
  Include/pyport.h:19:31: error: cast discards ‘const’ qualifier from
  pointer target type [-Werror=cast-qual]
    (...)
  Include/cpython/longintrepr.h:133:30: note: in expansion of macro
  ‘Py_TYPE’
    assert(PyType_HasFeature(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS));

16 months agogh-120593: Fix const qualifier in pyatomic.h (#121055)
Victor Stinner [Wed, 26 Jun 2024 18:10:47 +0000 (20:10 +0200)] 
gh-120593: Fix const qualifier in pyatomic.h (#121055)

16 months agogh-121008: Fix idlelib.run tests (#121046)
Victor Stinner [Wed, 26 Jun 2024 13:41:16 +0000 (15:41 +0200)] 
gh-121008: Fix idlelib.run tests (#121046)

When testing IDLE, don't create a Tk to avoid side effects such as
installing a PyOS_InputHook hook.