Commit Graph

124502 Commits

Author SHA1 Message Date
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
Hugo van Kemenade fc1042f9a6 Post 3.14.0a2 2024-11-19 21:55:02 +02:00
sobolevn 824afbf548
gh-109413: Enable mypy's `disallow_any_generics` setting when checking `libregrtest` (#127033) 2024-11-19 22:41:59 +03:00
Beomsoo Kim 8da9920a80
gh-126947: Typechecking for _pydatetime.timedelta.__new__ arguments (#126949)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-11-19 22:40:52 +03:00
CoderTCY 88dc84bcf9
gh-125729: Makes the installation of the turtle module dependent on the Tcl/Tk install option (GH-126176) 2024-11-19 17:19:33 +00:00
Justin Applegate 29cbcbd73b
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.
2024-11-19 18:00:35 +02:00
Malcolm Smith c5c9286804
gh-118201: Simplify conv_confname (#126089) 2024-11-19 10:42:19 -05:00
Hugo van Kemenade 5fcc3a4cee
Update docs 'make serve' to suggest 'make htmllive' (#126969) 2024-11-19 17:28:34 +02:00
Hugo van Kemenade add43c3420 Python 3.14.0a2 2024-11-19 16:52:44 +02:00
sobolevn 3932e1db53
gh-126980: Fix `bytearray.__buffer__` crash on `PyBUF_{READ,WRITE}` (#126981)
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-19 17:44:53 +03:00
Barney Gale 4d771977b1
GH-84850: Remove `urllib.request.URLopener` and `FancyURLopener` (#125739) 2024-11-19 16:01:49 +02:00
Mark Shannon a99dd23c1f
GH-124567: Replace quadratic assert with linear one (GH-127009) 2024-11-19 13:38:59 +00:00
Filipe Laíns 🇵🇸 6309e9e07a
codeowners: add myself to getpath, site, and venv (#126994)
Signed-off-by: Filipe Laíns <lains@riseup.net>
2024-11-19 12:43:34 +00:00
Pablo Galindo Salgado 30aeb00d36
gh-126076: Account for relocated objects in tracemalloc (#126077) 2024-11-19 10:35:17 +00:00
Hugo van Kemenade 899fdb213d
Revert "GH-126491: GC: Mark objects reachable from roots before doing cycle collection (GH-126502)" (#126983) 2024-11-19 11:25:09 +02:00
Victor Stinner 84f07c3a4c
gh-126594: Fix typeobject.c wrap_buffer() cast (#126754)
Reject flags smaller than INT_MIN.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-11-19 09:13:20 +01:00
Victor Stinner b3687ad454
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.
2024-11-19 09:08:42 +01:00
Eric Snow d6b3e78504
gh-126986: Drop _PyInterpreterState_FailIfNotRunning() (gh-126988)
We replace it with _PyErr_SetInterpreterAlreadyRunning().
2024-11-19 00:11:12 +00:00
Filipe Laíns 🇵🇸 0063f5f314
getpath: fix warning typo (#126978) 2024-11-18 23:50:01 +00:00
Brandt Bucher 4cd10762b0
GH-126795: Increase the JIT threshold from 16 to 4096 (GH-126816) 2024-11-18 11:11:23 -08:00
Hugo van Kemenade 933f21c3c9
gh-85957: Add missing MIME types for images with RFCs (#126966) 2024-11-18 20:13:20 +02:00
Serhiy Storchaka f7ef0203d4
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().
2024-11-18 17:45:25 +00:00
Stan U. 8fe1926164
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>
2024-11-18 17:29:14 +02:00
Mark Shannon b0fcc2c47a
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.
2024-11-18 14:31:26 +00:00