]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
11 months agoGH-115869: Make jit_stencils.h reproducible (GH-127166)
Brandt Bucher [Sun, 24 Nov 2024 22:42:50 +0000 (14:42 -0800)] 
GH-115869: Make jit_stencils.h reproducible (GH-127166)

11 months agoImprove `pathname2url()` and `url2pathname()` docs (#127125)
Barney Gale [Sun, 24 Nov 2024 17:33:46 +0000 (17:33 +0000)] 
Improve `pathname2url()` and `url2pathname()` docs (#127125)

These functions have long sown confusion among Python developers. The
existing documentation says they deal with URL path components, but that
doesn't fit the evidence on Windows:

    >>> pathname2url(r'C:\foo')
    '///C:/foo'
    >>> pathname2url(r'\\server\share')
    '////server/share'  # or '//server/share' as of quite recently

If these were URL path components, they would imply complete URLs like
`file://///C:/foo` and `file://////server/share`. Clearly this isn't right.
Yet the implementation in `nturl2path` is deliberate, and the
`url2pathname()` function correctly inverts it.

On non-Windows platforms, the behaviour until quite recently is to simply
quote/unquote the path without adding or removing any leading slashes. This
behaviour is compatible with *both* interpretations -- 1) the value is a
URL path component (existing docs), and 2) the value is everything
following `file:` (this commit)

The conclusion I draw is that these functions operate on everything after
the `file:` prefix, which may include an authority section. This is the
only explanation that fits both the  Windows and non-Windows behaviour.
It's also a better match for the function names.

11 months agogh-127217: Fix pathname2url() for paths starting with multiple slashes on Posix ...
Serhiy Storchaka [Sun, 24 Nov 2024 17:30:29 +0000 (19:30 +0200)] 
gh-127217: Fix pathname2url() for paths starting with multiple slashes on Posix (GH-127218)

11 months agoFix macro expansions in critical section docs (#127226)
da-woods [Sun, 24 Nov 2024 17:21:02 +0000 (17:21 +0000)] 
Fix macro expansions in critical section docs (#127226)

11 months agogh-122356: restore the position of a file-like object after `zipfile.is_zipfile`...
Bénédikt Tran [Sun, 24 Nov 2024 16:36:15 +0000 (17:36 +0100)] 
gh-122356: restore the position of a file-like object after `zipfile.is_zipfile` (#122397)

11 months agogh-101100: Fix sphinx warnings of removed opcodes (#127222)
Yuki Kobayashi [Sun, 24 Nov 2024 15:43:25 +0000 (00:43 +0900)] 
gh-101100: Fix sphinx warnings of removed opcodes (#127222)

11 months agoGH-127133: Remove ability to nest argument groups & mutually exclusive groups (#127186)
Savannah Ostrowski [Sun, 24 Nov 2024 15:20:37 +0000 (07:20 -0800)] 
GH-127133: Remove ability to nest argument groups & mutually exclusive groups (#127186)

11 months agogh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211)
Sergey B Kirpichev [Sun, 24 Nov 2024 07:37:37 +0000 (10:37 +0300)] 
gh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211)

`x**y == 1/x**-y ` thus changing `/=` to `*=` by negating the exponent.

11 months agogh-126662: harmonize naming for three namedtuple base classes in urllib.parse (GH...
Stephen Morton [Sun, 24 Nov 2024 02:36:48 +0000 (18:36 -0800)] 
gh-126662: harmonize naming for three namedtuple base classes in urllib.parse (GH-126663)

harmonize naming for three namedtuple base classes in urllib.parse

11 months agopathlib tests: move `walk()` tests into their own classes (GH-126651)
Barney Gale [Sun, 24 Nov 2024 02:31:00 +0000 (02:31 +0000)] 
pathlib tests: move `walk()` tests into their own classes (GH-126651)

Move tests for Path.walk() into a new PathWalkTest class, and apply a similar change in tests for the ABCs. This allows us to properly tear down the walk test hierarchy in tearDown(), rather than leaving it to os_helper.rmtree().

11 months agoFix "useable" typo in docs (#127200)
Stan U. [Sat, 23 Nov 2024 21:41:01 +0000 (21:41 +0000)] 
Fix "useable" typo in docs (#127200)

Fix typo in docs

11 months agoDoc: C API: Fix `Py_NewInterpreterFromConfig` example code (#126667)
Richard Hansen [Sat, 23 Nov 2024 19:47:08 +0000 (14:47 -0500)] 
Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (#126667)

11 months agoGH-125866: Preserve Windows drive letter case in file URIs (#127138)
Barney Gale [Sat, 23 Nov 2024 10:41:39 +0000 (10:41 +0000)] 
GH-125866: Preserve Windows drive letter case in file URIs (#127138)

Stop converting Windows drive letters to uppercase in
`urllib.request.pathname2url()` and `url2pathname()`. This behaviour is
unnecessary and inconsistent with pathlib's file URI implementation.

11 months agoGH-127134: Add note about forward compatibility for suggest_on_error (#127137)
Savannah Ostrowski [Sat, 23 Nov 2024 03:18:18 +0000 (19:18 -0800)] 
GH-127134: Add note about forward compatibility for suggest_on_error (#127137)

11 months agoFix a few typos found in the docs (GH-127126)
Rafael Fontenelle [Sat, 23 Nov 2024 00:02:51 +0000 (21:02 -0300)] 
Fix a few typos found in the docs (GH-127126)

11 months agogh-115999: Record success in `specialize` (#127167)
mpage [Fri, 22 Nov 2024 20:07:05 +0000 (12:07 -0800)] 
gh-115999: Record success in `specialize` (#127167)

Record success in `specialize`

This matches the existing behavior where we increment the success
stat for the generic opcode each time we successfully specialize
an instruction.

11 months agogh-119786: add code object doc, inline locations.md into it (#126832)
Irit Katriel [Fri, 22 Nov 2024 19:27:41 +0000 (19:27 +0000)] 
gh-119786: add code object doc, inline locations.md into it (#126832)

11 months agogh-109746: Make _thread.start_new_thread delete state of new thread on its startup...
Radislav Chugunov [Fri, 22 Nov 2024 19:20:07 +0000 (22:20 +0300)] 
gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761)

If Python fails to start newly created thread
due to failure of underlying PyThread_start_new_thread() call,
its state should be removed from interpreter' thread states list
to avoid its double cleanup.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
11 months agoGH-89435: os.path should not be a frozen module (#126924)
Filipe Laíns 🇵🇸 [Fri, 22 Nov 2024 18:50:30 +0000 (18:50 +0000)] 
GH-89435: os.path should not be a frozen module (#126924)

11 months agogh-127022: Simplify `PyStackRef_FromPyObjectSteal` (#127024)
Sam Gross [Fri, 22 Nov 2024 17:55:33 +0000 (17:55 +0000)] 
gh-127022: Simplify `PyStackRef_FromPyObjectSteal` (#127024)

This gets rid of the immortal check in `PyStackRef_FromPyObjectSteal()`.
Overall, this improves performance about 2% in the free threading
build.

This also renames `PyStackRef_Is()` to `PyStackRef_IsExactly()` because
the macro requires that the tag bits of the arguments match, which is
only true in certain special cases.

11 months agoEnable aarch64 Ubuntu CI jobs (#125786)
Łukasz Langa [Fri, 22 Nov 2024 17:29:18 +0000 (18:29 +0100)] 
Enable aarch64 Ubuntu CI jobs (#125786)

This change enables custom GHA runners for Ubuntu-24.04 that run on Arm hardware. It also prepares for Windows runners on Arm hardware, but doesn't enable that just yet, because the Arm GHA runner images for Windows need to be updated.

11 months agogh-115999: Add free-threaded specialization for `UNPACK_SEQUENCE` (#126600)
Kirill Podoprigora [Fri, 22 Nov 2024 17:00:35 +0000 (19:00 +0200)] 
gh-115999: Add free-threaded specialization for `UNPACK_SEQUENCE` (#126600)

Add free-threaded specialization for `UNPACK_SEQUENCE` opcode.
`UNPACK_SEQUENCE_TUPLE/UNPACK_SEQUENCE_TWO_TUPLE` are already thread safe since tuples are immutable.
`UNPACK_SEQUENCE_LIST` is not thread safe because of nature of lists (there is nothing preventing another thread from adding items to or removing them the list while the instruction is executing). To achieve thread safety we add a critical section to the implementation of `UNPACK_SEQUENCE_LIST`, especially around the parts where we check the size of the list and push items onto the stack.

---------

Co-authored-by: Matt Page <mpage@meta.com>
Co-authored-by: mpage <mpage@cs.stanford.edu>
11 months agogh-127117: Ensure the Correct Last Fields of PyInterpreterState and of _PyRuntimeStat...
Eric Snow [Fri, 22 Nov 2024 16:37:02 +0000 (09:37 -0700)] 
gh-127117: Ensure the Correct Last Fields of PyInterpreterState and of _PyRuntimeState (gh-127118)

We add some comments so contributors can be aware and we move one out-of-place field up.

11 months agogh-86463: Fix a trailing space in argparse.rst (#127162)
Serhiy Storchaka [Fri, 22 Nov 2024 16:34:05 +0000 (18:34 +0200)] 
gh-86463: Fix a trailing space in argparse.rst (#127162)

11 months agogh-88110: Clear concurrent.futures.thread._threads_queues after fork to avoid joining...
Andrei Bodrov [Fri, 22 Nov 2024 16:20:34 +0000 (19:20 +0300)] 
gh-88110: Clear concurrent.futures.thread._threads_queues after fork to avoid joining parent process' threads (GH-126098)

Threads are gone after fork, so clear the queues too. Otherwise the
child process (here created via multiprocessing.Process) crashes on
interpreter exit.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
11 months agogh-126384: Add tests to verify the behavior of basic COM methods. (GH-126610)
Jun Komoda [Fri, 22 Nov 2024 15:57:31 +0000 (00:57 +0900)] 
gh-126384: Add tests to verify the behavior of basic COM methods. (GH-126610)

11 months agogh-109413: Fix libregrtest get_running() (#127153)
Victor Stinner [Fri, 22 Nov 2024 15:56:03 +0000 (16:56 +0100)] 
gh-109413: Fix libregrtest get_running() (#127153)

Skip threads which are not running.

11 months agogh-127001: Fix PATHEXT issues in shutil.which() on Windows (GH-127035)
Serhiy Storchaka [Fri, 22 Nov 2024 15:52:15 +0000 (17:52 +0200)] 
gh-127001: Fix PATHEXT issues in shutil.which() on Windows (GH-127035)

* Name without a PATHEXT extension is only searched if the mode does not
  include X_OK.
* Support multi-component PATHEXT extensions (e.g. ".foo.bar").
* Support files without extensions in PATHEXT contains dot-only extension
  (".", "..", etc).
* Support PATHEXT extensions that end with a dot (e.g. ".foo.").

11 months agoFix broken XML in Visual Studio project file (GH-127142)
Sergey Muraviov [Fri, 22 Nov 2024 15:30:01 +0000 (18:30 +0300)] 
Fix broken XML in Visual Studio project file (GH-127142)

11 months agogh-86463: Fix default prog in subparsers if usage is used in the main parser (GH...
Serhiy Storchaka [Fri, 22 Nov 2024 15:29:33 +0000 (17:29 +0200)] 
gh-86463: Fix default prog in subparsers if usage is used in the main parser (GH-125891)

The usage parameter of argparse.ArgumentParser no longer
affects the default value of the prog parameter in subparsers.

Previously the full custom usage of the main parser was used as
the prog prefix in subparsers.

11 months agogh-127076: Ignore memory mmap in FileIO testing (#127088)
Cody Maloney [Fri, 22 Nov 2024 14:55:32 +0000 (06:55 -0800)] 
gh-127076: Ignore memory mmap in FileIO testing (#127088)

`mmap`, `munmap`, and `mprotect` are used by CPython for memory
management, which may occur in the middle of the FileIO tests. The
system calls can also be used with files, so `strace` includes them
in its `%file` and `%desc` filters.

Filter out the `mmap` system calls related to memory allocation for the
file tests. Currently FileIO doesn't do `mmap` at all, so didn't add
code to track from `mmap` through `munmap` since it wouldn't be used.
For now if an `mmap` on a fd happens, the call will be included (which
may cause test to fail), and at that time support for tracking the
address throug `munmap` could be added.

11 months agogh-126700: pygettext: Support more gettext functions (GH-126912)
Tomas R. [Fri, 22 Nov 2024 14:52:16 +0000 (15:52 +0100)] 
gh-126700: pygettext: Support more gettext functions (GH-126912)

Support multi-argument gettext functions: ngettext(), pgettext(), dgettext(), etc.

11 months agogh-127065: Make `methodcaller` thread-safe in free threading build (#127109)
Sam Gross [Fri, 22 Nov 2024 14:21:59 +0000 (14:21 +0000)] 
gh-127065: Make `methodcaller` thread-safe in free threading build (#127109)

The `methodcaller` C vectorcall implementation uses an arguments array
that is shared across calls. The first argument is modified on every
invocation. This isn't thread-safe in the free threading build. I think
it's also not safe in general, but for now just disable it in the free
threading build.

11 months agogh-127082: Replace "Windows only" with the `availability: Windows` in `ctypes` doc...
Jun Komoda [Fri, 22 Nov 2024 07:56:34 +0000 (16:56 +0900)] 
gh-127082: Replace "Windows only" with the `availability: Windows` in `ctypes` doc (#127099)

11 months agoAllow local use of `static PyMutex` in the C analyzer (#127102)
Peter Bierma [Fri, 22 Nov 2024 07:48:39 +0000 (02:48 -0500)] 
Allow local use of `static PyMutex` in the C analyzer (#127102)

11 months agoGH-127078: `url2pathname()`: handle extra slash before UNC drive in URL path (#127132)
Barney Gale [Fri, 22 Nov 2024 04:12:50 +0000 (04:12 +0000)] 
GH-127078: `url2pathname()`: handle extra slash before UNC drive in URL path (#127132)

Decode a file URI like `file://///server/share` as a UNC path like
`\\server\share`. This form of file URI is created by software the simply
prepends `file:///` to any absolute Windows path.

11 months agoGH-126766: `url2pathname()`: handle 'localhost' authority (#127129)
Barney Gale [Fri, 22 Nov 2024 03:17:06 +0000 (03:17 +0000)] 
GH-126766: `url2pathname()`: handle 'localhost' authority (#127129)

Discard any 'localhost' authority from the beginning of a `file:` URI. As a
result, file URIs like `//localhost/etc/hosts` are correctly decoded as
`/etc/hosts`.

11 months agoGH-122679: Add `register()` to argparse docs (#126939)
Savannah Ostrowski [Fri, 22 Nov 2024 00:36:11 +0000 (16:36 -0800)] 
GH-122679: Add `register()` to argparse docs (#126939)

* Add register() to argparse docs

* Add newline

* Formatting

* Fix codeblock

* Move section

* Add signature

* Add newline

* Fix indent

* Fix indent take 2

* Rephrase

* Simplify language

* Address PR comments

* Add references to register in type and action

* Remove unnecessary reference

* Rephrase and add success case

11 months agoGH-126601: `pathname2url()`: handle NTFS alternate data streams (#126760)
Barney Gale [Fri, 22 Nov 2024 00:29:05 +0000 (00:29 +0000)] 
GH-126601: `pathname2url()`: handle NTFS alternate data streams (#126760)

Adjust `pathname2url()` to encode embedded colon characters in Windows
paths, rather than bailing out with an `OSError`.

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
11 months agogh-126091: Always link generator frames when propagating a thrown-in exception throug...
Jacob Bower [Thu, 21 Nov 2024 23:37:49 +0000 (15:37 -0800)] 
gh-126091: Always link generator frames when propagating a thrown-in exception through a yield-from chain (#126092)

Always link generator frames when propagating a thrown-in exception through a yield-from chain.

11 months agoImprove comment for co_nlocalsplus (#126993)
Jacob Bower [Thu, 21 Nov 2024 23:26:25 +0000 (15:26 -0800)] 
Improve comment for co_nlocalsplus (#126993)

11 months agogh-115999: Add free-threaded specialization for ``TO_BOOL`` (gh-126616)
Donghee Na [Thu, 21 Nov 2024 22:52:16 +0000 (07:52 +0900)] 
gh-115999: Add free-threaded specialization for ``TO_BOOL`` (gh-126616)

11 months agogh-115999: Specialize `LOAD_GLOBAL` in free-threaded builds (#126607)
mpage [Thu, 21 Nov 2024 19:22:21 +0000 (11:22 -0800)] 
gh-115999: Specialize `LOAD_GLOBAL` in free-threaded builds (#126607)

Enable specialization of LOAD_GLOBAL in free-threaded builds.

Thread-safety of specialization in free-threaded builds is provided by the following:

A critical section is held on both the globals and builtins objects during specialization. This ensures we get an atomic view of both builtins and globals during specialization.
Generation of new keys versions is made atomic in free-threaded builds.
Existing helpers are used to atomically modify the opcode.
Thread-safety of specialized instructions in free-threaded builds is provided by the following:

Relaxed atomics are used when loading and storing dict keys versions. This avoids potential data races as the dict keys versions are read without holding the dictionary's per-object lock in version guards.
Dicts keys objects are passed from keys version guards to the downstream uops. This ensures that we are loading from the correct offset in the keys object. Once a unicode key has been stored in a keys object for a combined dictionary in free-threaded builds, the offset that it is stored in will never be reused for a different key. Once the version guard passes, we know that we are reading from the correct offset.
The dictionary read fast-path is used to read values from the dictionary once we know the correct offset.

11 months agogh-114940: Add _Py_FOR_EACH_TSTATE_UNLOCKED(), and Friends (gh-127077)
Eric Snow [Thu, 21 Nov 2024 18:08:38 +0000 (11:08 -0700)] 
gh-114940: Add _Py_FOR_EACH_TSTATE_UNLOCKED(), and Friends (gh-127077)

This is a precursor to the actual fix for gh-114940, where we will change these macros to use the new lock.  This change is almost entirely mechanical; the exceptions are the loops in codeobject.c and ceval.c, which now hold the "head" lock.  Note that almost all of the uses of _Py_FOR_EACH_TSTATE_UNLOCKED() here will change to _Py_FOR_EACH_TSTATE_BEGIN() once we add the new per-interpreter lock.

11 months agogh-124470: Fix crash when reading from object instance dictionary while replacing...
Dino Viehland [Thu, 21 Nov 2024 16:41:19 +0000 (08:41 -0800)] 
gh-124470: Fix crash when reading from object instance dictionary while replacing it (#122489)

Delay free a dictionary when replacing it

11 months agogh-127020: Make `PyCode_GetCode` thread-safe for free threading (#127043)
Sam Gross [Thu, 21 Nov 2024 16:00:50 +0000 (16:00 +0000)] 
gh-127020: Make `PyCode_GetCode` thread-safe for free threading (#127043)

Some fields in PyCodeObject are lazily initialized. Use atomics and
critical sections to make their initializations and accesses thread-safe.

11 months agogh-118761: Improve import time of `mimetypes` (#126979)
Hugo van Kemenade [Thu, 21 Nov 2024 14:55:28 +0000 (16:55 +0200)] 
gh-118761: Improve import time of `mimetypes` (#126979)

11 months agogh-124873: Tolerate 100 ms in TimerfdTests on Android (#127101)
Victor Stinner [Thu, 21 Nov 2024 14:53:52 +0000 (15:53 +0100)] 
gh-124873: Tolerate 100 ms in TimerfdTests on Android (#127101)

On Android, TimerfdTests of test_os now uses 100 ms accuracy instead
of 10 ms.

11 months agogh-126316: Make grp.getgrall() thread-safe: add a mutex (#127055)
Victor Stinner [Thu, 21 Nov 2024 14:47:24 +0000 (15:47 +0100)] 
gh-126316: Make grp.getgrall() thread-safe: add a mutex (#127055)

grpmodule.c is no longer built with the limited C API, since PyMutex
is excluded from the limited C API.

11 months agogh-126780: Fix `ntpath.normpath()` for drive-relative paths (GH-126801)
Nice Zombies [Thu, 21 Nov 2024 14:43:36 +0000 (15:43 +0100)] 
gh-126780: Fix `ntpath.normpath()` for drive-relative paths (GH-126801)

11 months agogh-112136: Remove unused #include "pycore_lock.h" (#127093)
Victor Stinner [Thu, 21 Nov 2024 12:50:11 +0000 (13:50 +0100)] 
gh-112136: Remove unused #include "pycore_lock.h" (#127093)

pycore_modsupport.h no longer needs pycore_lock.h.

11 months agogh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730)
Serhiy Storchaka [Thu, 21 Nov 2024 11:16:08 +0000 (13:16 +0200)] 
gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730)

It now returns multiple era description segments separated by semicolons.
Previously it only returned the first segment on platforms with Glibc.

11 months agogh-126997: Fix support of non-ASCII strings in pickletools (GH-127062)
Serhiy Storchaka [Thu, 21 Nov 2024 11:15:12 +0000 (13:15 +0200)] 
gh-126997: Fix support of non-ASCII strings in pickletools (GH-127062)

* Fix support of STRING and GLOBAL opcodes with non-ASCII arguments.
* dis() now outputs non-ASCII bytes in STRING, BINSTRING and
  SHORT_BINSTRING arguments as escaped (\xXX).

11 months agogh-127076: Disable strace tests under LD_PRELOAD (#127086)
Cody Maloney [Thu, 21 Nov 2024 09:33:12 +0000 (01:33 -0800)] 
gh-127076: Disable strace tests under LD_PRELOAD (#127086)

Distribution tooling (ex. sandbox on Gentoo and fakeroot on Debian) uses
LD_PRELOAD to intercept system calls and potentially modify them when
building. These tools can change the set of system calls, so disable
system call testing under these cases.

Co-authored-by: Michał Górny <mgorny@gentoo.org>
11 months agogh-126898: Emscripten support: Use es6 modules (#126903)
Hood Chatham [Thu, 21 Nov 2024 04:10:46 +0000 (05:10 +0100)] 
gh-126898: Emscripten support: Use es6 modules (#126903)

Modify Emscripten support to use ES6 modules.

11 months agogh-115999: Don't take a reason in unspecialize (#127030)
mpage [Wed, 20 Nov 2024 22:54:48 +0000 (14:54 -0800)] 
gh-115999: Don't take a reason in unspecialize (#127030)

Don't take a reason in unspecialize

We only want to compute the reason if stats are enabled. Optimizing
compilers should optimize this away for us (gcc and clang do), but
it's better to be safe than sorry.

11 months agoRun `apt update` before `apt install git` in autoconf CI job (GH-127066)
Zachary Ware [Wed, 20 Nov 2024 19:20:44 +0000 (13:20 -0600)] 
Run `apt update` before `apt install git` in autoconf CI job (GH-127066)

11 months agoMove NEWS entries out of directories with spaces (GH-127067)
Zachary Ware [Wed, 20 Nov 2024 18:52:46 +0000 (12:52 -0600)] 
Move NEWS entries out of directories with spaces (GH-127067)

Cleanup after GH-126063, including moving the `README.rst` files to the new directories.

11 months agogh-121058: Warn if `PyThreadState_Clear` is called with an exception set (gh-121343)
Peter Bierma [Wed, 20 Nov 2024 17:27:19 +0000 (12:27 -0500)] 
gh-121058: Warn if `PyThreadState_Clear` is called with an exception set (gh-121343)

11 months agoGH-127010: Don't lazily track and untrack dicts (GH-127027)
Mark Shannon [Wed, 20 Nov 2024 16:41:20 +0000 (16:41 +0000)] 
GH-127010: Don't lazily track and untrack dicts (GH-127027)

11 months agogh-97514: Authenticate the forkserver control socket. (GH-99309)
Gregory P. Smith [Wed, 20 Nov 2024 16:18:58 +0000 (08:18 -0800)] 
gh-97514: Authenticate the forkserver control socket. (GH-99309)

This adds authentication to the forkserver control socket. In the past only filesystem permissions protected this socket from code injection into the forkserver process by limiting access to the same UID, which didn't exist when Linux abstract namespace sockets were used (see issue) meaning that any process in the same system network namespace could inject code. We've since stopped using abstract namespace sockets by default, but protecting our control sockets regardless of type is a good idea.

This reuses the HMAC based shared key auth already used by `multiprocessing.connection` sockets for other purposes.

Doing this is useful so that filesystem permissions are not relied upon and trust isn't implied by default between all processes running as the same UID with access to the unix socket.

### pyperformance benchmarks

No significant changes. Including `concurrent_imap` which exercises `multiprocessing.Pool.imap` in that suite.

### Microbenchmarks

This does _slightly_ slow down forkserver use. How much so appears to depend on the platform. Modern platforms and simple platforms are less impacted. This PR adds additional IPC round trips to the control socket to tell forkserver to spawn a new process. Systems with potentially high latency IPC are naturally impacted more.

Typically a 1-4% slowdown on a very targeted process creation microbenchmark, with a worst case overloaded system slowdown of 20%.  No evidence that these slowdowns appear in practical sense.  See the PR for details.

11 months agoGH-126892: Reset warmup counters when JIT compiling code (GH-126893)
Brandt Bucher [Wed, 20 Nov 2024 16:11:25 +0000 (08:11 -0800)] 
GH-126892: Reset warmup counters when JIT compiling code (GH-126893)

11 months agogh-126991: Add tests for unpickling bad object state (GH-127031)
Serhiy Storchaka [Wed, 20 Nov 2024 15:31:50 +0000 (17:31 +0200)] 
gh-126991: Add tests for unpickling bad object state (GH-127031)

This catches a memory leak in loading the BUILD opcode.

11 months agogh-126615: `ctypes`: Make `COMError` public (GH-126686)
Jun Komoda [Wed, 20 Nov 2024 12:53:43 +0000 (21:53 +0900)] 
gh-126615: `ctypes`: Make `COMError` public (GH-126686)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
11 months agoGH-84850: Improve whatsnew entry for `[Fancy]URLopener` removal (#127032)
Barney Gale [Wed, 20 Nov 2024 11:14:07 +0000 (11:14 +0000)] 
GH-84850: Improve whatsnew entry for `[Fancy]URLopener` removal (#127032)

11 months agogh-123299: Copyedit "What's New in Python 3.14" (#127028)
Hugo van Kemenade [Wed, 20 Nov 2024 09:35:24 +0000 (11:35 +0200)] 
gh-123299: Copyedit "What's New in Python 3.14" (#127028)

11 months agoDoc: C API: `PyThreadState::on_delete` was removed in v3.13 (#126536)
Richard Hansen [Wed, 20 Nov 2024 08:44:45 +0000 (03:44 -0500)] 
Doc: C API: `PyThreadState::on_delete` was removed in v3.13 (#126536)

11 months agoGH-85168: Use filesystem encoding when converting to/from `file` URIs (#126852)
Barney Gale [Tue, 19 Nov 2024 21:19:30 +0000 (21:19 +0000)] 
GH-85168: Use filesystem encoding when converting to/from `file` URIs (#126852)

Adjust `urllib.request.url2pathname()` and `pathname2url()` to use the
filesystem encoding when quoting and unquoting file URIs, rather than
forcing use of UTF-8.

No changes are needed in the `nturl2path` module because Windows always
uses UTF-8, per PEP 529.

11 months agoMerge remote-tracking branch 'upstream/main'
Hugo van Kemenade [Tue, 19 Nov 2024 20:10:24 +0000 (22:10 +0200)] 
Merge remote-tracking branch 'upstream/main'

11 months agogh-126914: Store the Preallocated Thread State's Pointer in a PyInterpreterState...
Eric Snow [Tue, 19 Nov 2024 19:59:19 +0000 (12:59 -0700)] 
gh-126914: Store the Preallocated Thread State's Pointer in a PyInterpreterState Field (gh-126989)

This approach eliminates the originally reported race. It also gets rid of the deadlock reported in gh-96071, so we can remove the workaround added then.

11 months agoPost 3.14.0a2
Hugo van Kemenade [Tue, 19 Nov 2024 19:55:02 +0000 (21:55 +0200)] 
Post 3.14.0a2

11 months agogh-109413: Enable mypy's `disallow_any_generics` setting when checking `libregrtest...
sobolevn [Tue, 19 Nov 2024 19:41:59 +0000 (22:41 +0300)] 
gh-109413: Enable mypy's `disallow_any_generics` setting when checking `libregrtest` (#127033)

11 months agogh-126947: Typechecking for _pydatetime.timedelta.__new__ arguments (#126949)
Beomsoo Kim [Tue, 19 Nov 2024 19:40:52 +0000 (04:40 +0900)] 
gh-126947: Typechecking for _pydatetime.timedelta.__new__ arguments (#126949)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
11 months agogh-125729: Makes the installation of the turtle module dependent on the Tcl/Tk instal...
CoderTCY [Tue, 19 Nov 2024 17:19:33 +0000 (01:19 +0800)] 
gh-125729: Makes the installation of the turtle module dependent on the Tcl/Tk install option  (GH-126176)

11 months agogh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990)
Justin Applegate [Tue, 19 Nov 2024 16:00:35 +0000 (11:00 -0500)] 
gh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990)

If PyObject_SetItem() fails in the `load_build()` function of _pickle.c, no DECREF for the `dict` variable.

11 months agogh-118201: Simplify conv_confname (#126089)
Malcolm Smith [Tue, 19 Nov 2024 15:42:19 +0000 (15:42 +0000)] 
gh-118201: Simplify conv_confname (#126089)

11 months agoUpdate docs 'make serve' to suggest 'make htmllive' (#126969)
Hugo van Kemenade [Tue, 19 Nov 2024 15:28:34 +0000 (17:28 +0200)] 
Update docs 'make serve' to suggest 'make htmllive' (#126969)

11 months agoPython 3.14.0a2 v3.14.0a2
Hugo van Kemenade [Tue, 19 Nov 2024 14:51:57 +0000 (16:51 +0200)] 
Python 3.14.0a2

11 months agogh-126980: Fix `bytearray.__buffer__` crash on `PyBUF_{READ,WRITE}` (#126981)
sobolevn [Tue, 19 Nov 2024 14:44:53 +0000 (17:44 +0300)] 
gh-126980: Fix `bytearray.__buffer__` crash on `PyBUF_{READ,WRITE}` (#126981)

Co-authored-by: Victor Stinner <vstinner@python.org>
11 months agoGH-84850: Remove `urllib.request.URLopener` and `FancyURLopener` (#125739)
Barney Gale [Tue, 19 Nov 2024 14:01:49 +0000 (14:01 +0000)] 
GH-84850: Remove `urllib.request.URLopener` and `FancyURLopener` (#125739)

11 months agoGH-124567: Replace quadratic assert with linear one (GH-127009)
Mark Shannon [Tue, 19 Nov 2024 13:38:59 +0000 (13:38 +0000)] 
GH-124567: Replace quadratic assert with linear one (GH-127009)

11 months agocodeowners: add myself to getpath, site, and venv (#126994)
Filipe Laíns 🇵🇸 [Tue, 19 Nov 2024 12:43:34 +0000 (12:43 +0000)] 
codeowners: add myself to getpath, site, and venv (#126994)

Signed-off-by: Filipe Laíns <lains@riseup.net>
11 months agogh-126076: Account for relocated objects in tracemalloc (#126077)
Pablo Galindo Salgado [Tue, 19 Nov 2024 10:35:17 +0000 (10:35 +0000)] 
gh-126076: Account for relocated objects in tracemalloc (#126077)

11 months agoRevert "GH-126491: GC: Mark objects reachable from roots before doing cycle collectio...
Hugo van Kemenade [Tue, 19 Nov 2024 09:25:09 +0000 (11:25 +0200)] 
Revert "GH-126491: GC: Mark objects reachable from roots before doing cycle collection (GH-126502)" (#126983)

11 months agogh-126594: Fix typeobject.c wrap_buffer() cast (#126754)
Victor Stinner [Tue, 19 Nov 2024 08:13:20 +0000 (09:13 +0100)] 
gh-126594: Fix typeobject.c wrap_buffer() cast (#126754)

Reject flags smaller than INT_MIN.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
11 months agogh-126876: Fix socket internal_select() for large timeout (#126968)
Victor Stinner [Tue, 19 Nov 2024 08:08:42 +0000 (09:08 +0100)] 
gh-126876: Fix socket internal_select() for large timeout (#126968)

If the timeout is larger than INT_MAX, replace it with INT_MAX, in
the poll() code path.

Add an unit test.

11 months agogh-126986: Drop _PyInterpreterState_FailIfNotRunning() (gh-126988)
Eric Snow [Tue, 19 Nov 2024 00:11:12 +0000 (17:11 -0700)] 
gh-126986: Drop _PyInterpreterState_FailIfNotRunning() (gh-126988)

We replace it with _PyErr_SetInterpreterAlreadyRunning().

11 months agogetpath: fix warning typo (#126978)
Filipe Laíns 🇵🇸 [Mon, 18 Nov 2024 23:50:01 +0000 (23:50 +0000)] 
getpath: fix warning typo (#126978)

11 months agoGH-126795: Increase the JIT threshold from 16 to 4096 (GH-126816)
Brandt Bucher [Mon, 18 Nov 2024 19:11:23 +0000 (11:11 -0800)] 
GH-126795: Increase the JIT threshold from 16 to 4096 (GH-126816)

11 months agogh-85957: Add missing MIME types for images with RFCs (#126966)
Hugo van Kemenade [Mon, 18 Nov 2024 18:13:20 +0000 (20:13 +0200)] 
gh-85957: Add missing MIME types for images with RFCs (#126966)

11 months agogh-123803: Support arbitrary code page encodings on Windows (GH-123804)
Serhiy Storchaka [Mon, 18 Nov 2024 17:45:25 +0000 (19:45 +0200)] 
gh-123803: Support arbitrary code page encodings on Windows (GH-123804)

If the cpXXX encoding is not directly implemented in Python, fall back
to use the Windows-specific API codecs.code_page_encode() and
codecs.code_page_decode().

11 months agogh-126911: Update credits output (#126913)
Stan U. [Mon, 18 Nov 2024 15:29:14 +0000 (15:29 +0000)] 
gh-126911: Update credits output (#126913)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
11 months agoGH-126491: GC: Mark objects reachable from roots before doing cycle collection (GH...
Mark Shannon [Mon, 18 Nov 2024 14:31:26 +0000 (14:31 +0000)] 
GH-126491: GC: Mark objects reachable from roots before doing cycle collection (GH-126502)

* Mark almost all reachable objects before doing collection phase

* Add stats for objects marked

* Visit new frames before each increment

* Remove lazy dict tracking

* Update docs

* Clearer calculation of work to do.

11 months agogh-109413: Enable `strict_optional = true` for `libregrtest/run_workers` (#126855)
sobolevn [Mon, 18 Nov 2024 14:23:43 +0000 (17:23 +0300)] 
gh-109413: Enable `strict_optional = true` for `libregrtest/run_workers` (#126855)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
11 months agogh-126909: Fix running xattr tests on systems with lower limits (#126930)
Michał Górny [Mon, 18 Nov 2024 13:05:55 +0000 (13:05 +0000)] 
gh-126909: Fix running xattr tests on systems with lower limits (#126930)

Modify the extended attribute tests to write fewer and smaller extended
attributes, in order to fit within filesystems with total xattr limit
of 1 KiB (e.g. ext4 with 1 KiB blocks).  Previously, the test would
write over 2 KiB, making it fail with ENOSPC on such systems.

11 months agogh-101955: Fix SystemError in possesive quantifier with alternative and group (GH...
Serhiy Storchaka [Mon, 18 Nov 2024 11:43:44 +0000 (13:43 +0200)] 
gh-101955: Fix SystemError in possesive quantifier with alternative and group (GH-111362)

Co-authored-by: <wjssz@users.noreply.github.com>
11 months agogh-67877: Fix memory leaks in terminated RE matching (GH-126840)
Serhiy Storchaka [Mon, 18 Nov 2024 09:53:45 +0000 (11:53 +0200)] 
gh-67877: Fix memory leaks in terminated RE matching (GH-126840)

If SRE(match) function terminates abruptly, either because of a signal
or because memory allocation fails, allocated SRE_REPEAT blocks might
be never released.

Co-authored-by: <wjssz@users.noreply.github.com>
11 months agogh-126789: Correct sysconfig test exclusions for iOS and Android. (GH-126941)
Russell Keith-Magee [Mon, 18 Nov 2024 08:50:40 +0000 (16:50 +0800)] 
gh-126789: Correct sysconfig test exclusions for iOS and Android. (GH-126941)

11 months agoDoc: Reorganize math module documentation (#126337)
Joseph Martinot-Lagarde [Mon, 18 Nov 2024 07:57:32 +0000 (08:57 +0100)] 
Doc: Reorganize math module documentation (#126337)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
11 months agogh-126167: Modify iOS Testbed to read arguments from Info.plist (#126169)
Russell Keith-Magee [Sun, 17 Nov 2024 23:43:41 +0000 (07:43 +0800)] 
gh-126167: Modify iOS Testbed to read arguments from Info.plist (#126169)

Modify iOS Testbed to read arguments from Info.plist.