Commit Graph

124525 Commits

Author SHA1 Message Date
Łukasz Langa
8214e0f709
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.
2024-11-22 18:29:18 +01:00
Kirill Podoprigora
27486c3365
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>
2024-11-22 19:00:35 +02:00
Eric Snow
5ba67af006
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.
2024-11-22 09:37:02 -07:00
Serhiy Storchaka
a5440d4a38
gh-86463: Fix a trailing space in argparse.rst (#127162) 2024-11-22 16:34:05 +00:00
Andrei Bodrov
1848ce61f3
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>
2024-11-22 18:20:34 +02:00
Jun Komoda
7725c0371a
gh-126384: Add tests to verify the behavior of basic COM methods. (GH-126610) 2024-11-22 16:57:31 +01:00
Victor Stinner
0cb20177d6
gh-109413: Fix libregrtest get_running() (#127153)
Skip threads which are not running.
2024-11-22 16:56:03 +01:00
Serhiy Storchaka
8899e85de1
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.").
2024-11-22 17:52:15 +02:00
Sergey Muraviov
615abb99a4
Fix broken XML in Visual Studio project file (GH-127142) 2024-11-22 15:30:01 +00:00
Serhiy Storchaka
0cb4d6c654
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.
2024-11-22 17:29:33 +02:00
Cody Maloney
46f8a7bbdb
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.
2024-11-22 15:55:32 +01:00
Tomas R.
0a1944cda8
gh-126700: pygettext: Support more gettext functions (GH-126912)
Support multi-argument gettext functions: ngettext(), pgettext(), dgettext(), etc.
2024-11-22 16:52:16 +02:00
Sam Gross
f83ca6962a
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.
2024-11-22 09:21:59 -05:00
Jun Komoda
3c770e3f09
gh-127082: Replace "Windows only" with the availability: Windows in ctypes doc (#127099) 2024-11-22 08:56:34 +01:00
Peter Bierma
89125e9f9f
Allow local use of static PyMutex in the C analyzer (#127102) 2024-11-22 08:48:39 +01:00
Barney Gale
8c98ed846a
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.
2024-11-22 04:12:50 +00:00
Barney Gale
ebf564a1d3
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`.
2024-11-22 03:17:06 +00:00
Savannah Ostrowski
fcfdb55465
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
2024-11-21 16:36:11 -08:00
Barney Gale
fd133d4f21
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>
2024-11-22 00:29:05 +00:00
Jacob Bower
e8bb053941
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.
2024-11-21 17:37:49 -06:00
Jacob Bower
3fafc1bd83
Improve comment for co_nlocalsplus (#126993) 2024-11-21 17:26:25 -06:00
Donghee Na
78a530a578
gh-115999: Add free-threaded specialization for `TO_BOOL` (gh-126616) 2024-11-22 07:52:16 +09:00
mpage
09c240f20c
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.
2024-11-21 11:22:21 -08:00
Eric Snow
9dabace39d
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.
2024-11-21 11:08:38 -07:00
Dino Viehland
bf542f8bb9
gh-124470: Fix crash when reading from object instance dictionary while replacing it (#122489)
Delay free a dictionary when replacing it
2024-11-21 10:41:19 -06:00
Sam Gross
3926842117
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.
2024-11-21 11:00:50 -05:00
Hugo van Kemenade
dc7a2b6522
gh-118761: Improve import time of mimetypes (#126979) 2024-11-21 16:55:28 +02:00
Victor Stinner
bab4b0462e
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.
2024-11-21 15:53:52 +01:00
Victor Stinner
3c2bd66e21
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.
2024-11-21 15:47:24 +01:00
Nice Zombies
60ec854bc2
gh-126780: Fix ntpath.normpath() for drive-relative paths (GH-126801) 2024-11-21 14:43:36 +00:00
Victor Stinner
0c5556fcb7
gh-112136: Remove unused #include "pycore_lock.h" (#127093)
pycore_modsupport.h no longer needs pycore_lock.h.
2024-11-21 13:50:11 +01:00
Serhiy Storchaka
4803cd0244
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.
2024-11-21 13:16:08 +02:00
Serhiy Storchaka
eaf2171082
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).
2024-11-21 13:15:12 +02:00
Cody Maloney
ff2278e2bf
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>
2024-11-21 10:33:12 +01:00
Hood Chatham
1629d2ca56
gh-126898: Emscripten support: Use es6 modules (#126903)
Modify Emscripten support to use ES6 modules.
2024-11-21 15:10:46 +11:00
mpage
32428cf9ea
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.
2024-11-20 14:54:48 -08:00
Zachary Ware
0af4ec30bd
Run apt update before apt install git in autoconf CI job (GH-127066) 2024-11-20 19:20:44 +00:00
Zachary Ware
2c9911abe6
Move NEWS entries out of directories with spaces (GH-127067)
Cleanup after GH-126063, including moving the `README.rst` files to the new directories.
2024-11-20 18:52:46 +00:00
Peter Bierma
6c1a4fb6d4
gh-121058: Warn if PyThreadState_Clear is called with an exception set (gh-121343) 2024-11-20 10:27:19 -07:00
Mark Shannon
aea0c586d1
GH-127010: Don't lazily track and untrack dicts (GH-127027) 2024-11-20 16:41:20 +00:00
Gregory P. Smith
7191b7662e
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.
2024-11-20 08:18:58 -08:00
Brandt Bucher
48c50ff1a2
GH-126892: Reset warmup counters when JIT compiling code (GH-126893) 2024-11-20 08:11:25 -08:00
Serhiy Storchaka
addb225f38
gh-126991: Add tests for unpickling bad object state (GH-127031)
This catches a memory leak in loading the BUILD opcode.
2024-11-20 17:31:50 +02:00
Jun Komoda
5b4502560b
gh-126615: ctypes: Make COMError public (GH-126686)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-11-20 12:53:43 +00:00
Barney Gale
9d2a879aff
GH-84850: Improve whatsnew entry for [Fancy]URLopener removal (#127032) 2024-11-20 13:14:07 +02:00
Hugo van Kemenade
3746d0a7b3
gh-123299: Copyedit "What's New in Python 3.14" (#127028) 2024-11-20 11:35:24 +02:00
Richard Hansen
9bca3ef575
Doc: C API: PyThreadState::on_delete was removed in v3.13 (#126536) 2024-11-20 09:44:45 +01:00
Barney Gale
c9b399fbdb
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.
2024-11-19 21:19:30 +00:00
Hugo van Kemenade
2cdfb41d0c Merge remote-tracking branch 'upstream/main' 2024-11-19 22:10:24 +02:00
Eric Snow
1c0a104eca
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.
2024-11-19 12:59:19 -07:00