0
0
mirror of https://github.com/python/cpython.git synced 2024-11-24 08:52:25 +01:00
Commit Graph

123494 Commits

Author SHA1 Message Date
Miss Islington (bot)
69472a5760
[3.13] gh-126991: Add tests for unpickling bad object state (GH-127031) (GH-127063)
This catches a memory leak in loading the BUILD opcode.
(cherry picked from commit addb225f38)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-24 03:16:54 +00:00
Miss Islington (bot)
a8e69fc68d
[3.13] gh-126896: Fix docs about asyncio.start_server() (GH-126897) (GH-126934)
gh-126896: Fix docs about `asyncio.start_server()` (GH-126897)
(cherry picked from commit 0c5c80928c)

Co-authored-by: beavailable <beavailable@proton.me>
2024-11-23 18:55:58 -08:00
Miss Islington (bot)
9dbce9f382
[3.13] Fix "useable" typo in docs (GH-127200) (#127207)
Fix "useable" typo in docs (GH-127200)

Fix typo in docs
(cherry picked from commit dbd23790db)

Co-authored-by: Stan U <89152624+StanFromIreland@users.noreply.github.com>
2024-11-23 17:50:06 -05:00
Miss Islington (bot)
b1a241ef4c
[3.13] Doc: C API: Fix Py_NewInterpreterFromConfig example code (GH-126667) (#127201)
Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (GH-126667)
(cherry picked from commit e3038e976b)

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2024-11-23 19:54:12 +00:00
Łukasz Langa
d87fb9c30d
[3.13] Enable aarch64 Ubuntu CI jobs (GH-125786) (GH-127170)
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.
(cherry picked from commit 8214e0f709)
2024-11-23 10:40:25 +01:00
Miss Islington (bot)
9291095a74
[3.13] Fix a few typos found in the docs (GH-127126) (GH-127181)
Fix a few typos found in the docs (GH-127126)
(cherry picked from commit 39e60aeb38)

Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>
2024-11-23 00:09:35 +00:00
Serhiy Storchaka
75ef92da29
[3.13] gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761) (GH-127171)
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.

(cherry picked from commit ca3ea9ad05)

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
2024-11-22 19:55:44 +00:00
Damien
950daf8765
[3.13] gh-122544: Change OS image in GitHub Actions to Ubuntu 24.04 (#122566) (#126619)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-11-22 20:18:57 +01:00
Miss Islington (bot)
329865b883
[3.13] gh-88110: Clear concurrent.futures.thread._threads_queues after fork to avoid joining parent process' threads (GH-126098) (GH-127163)
Threads are gone after fork, so clear the queues too. Otherwise the
child process (here created via multiprocessing.Process) crashes on
interpreter exit.

(cherry picked from commit 1848ce61f3)

Co-authored-by: Andrei Bodrov <Drino@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-22 17:08:18 +00:00
Miss Islington (bot)
f0d1a20b77
[3.13] gh-109413: Fix libregrtest get_running() (GH-127153) (#127157)
gh-109413: Fix libregrtest get_running() (GH-127153)

Skip threads which are not running.
(cherry picked from commit 0cb20177d6)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-22 16:34:07 +00:00
Miss Islington (bot)
7f22b87d35
[3.13] gh-127001: Fix PATHEXT issues in shutil.which() on Windows (GH-127035) (GH-127156)
* 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.").
(cherry picked from commit 8899e85de1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-22 16:18:44 +00:00
Miss Islington (bot)
5468d219df
[3.13] gh-127065: Make methodcaller thread-safe in free threading build (GH-127109) (GH-127150)
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.
(cherry picked from commit f83ca6962a)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-11-22 14:51:40 +00:00
Miss Islington (bot)
1b58c0f308
[3.13] GH-122679: Add register() to argparse docs (GH-126939) (GH-127149)
(cherry picked from commit fcfdb55465)

Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
2024-11-22 16:12:05 +02:00
Jun Komoda
af00c58652
[3.13] gh-127082: Replace "Windows only" with the availability: Windows in ctypes doc (GH-127099) (#127144)
(cherry picked from commit 3c770e3f09)
2024-11-22 14:09:53 +01:00
Miss Islington (bot)
7bbcd32e59
[3.13] GH-127078: url2pathname(): handle extra slash before UNC drive in URL path (GH-127132) (#127135)
GH-127078: `url2pathname()`: handle extra slash before UNC drive in URL path (GH-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.
(cherry picked from commit 8c98ed846a)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2024-11-22 04:37:30 +00:00
Miss Islington (bot)
4b9068eeea
[3.13] GH-126766: url2pathname(): handle 'localhost' authority (GH-127129) (#127130)
GH-126766: `url2pathname()`: handle 'localhost' authority (GH-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`.
(cherry picked from commit ebf564a1d3)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2024-11-22 03:42:26 +00:00
Eric Snow
8cdd636f87
[3.13] gh-126986: Stop Using _PyInterpreterState_FailIfNotRunning() (gh-127112)
This is a pseudo-backport of d6b3e78 (gh-126988).  In that change for 3.14+, we dropped _PyInterpreterState_FailIfNotRunning() and added _PyErr_SetInterpreterAlreadyRunning().  Here, we replace usage of _PyInterpreterState_FailIfNotRunning() with the inlined equivalent of _PyErr_SetInterpreterAlreadyRunning(), without adding that function.  That way we avoid changing the 3.13 ABI.
2024-11-21 10:33:15 -07:00
Miss Islington (bot)
c74331413e
[3.13] gh-127020: Make PyCode_GetCode thread-safe for free threading (GH-127043) (GH-127107)
Some fields in PyCodeObject are lazily initialized. Use atomics and
critical sections to make their initializations and accesses thread-safe.
(cherry picked from commit 3926842117)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-11-21 16:27:36 +00:00
Miss Islington (bot)
c09366b1fe
[3.13] gh-124873: Tolerate 100 ms in TimerfdTests on Android (GH-127101) (#127105)
gh-124873: Tolerate 100 ms in TimerfdTests on Android (GH-127101)

On Android, TimerfdTests of test_os now uses 100 ms accuracy instead
of 10 ms.
(cherry picked from commit bab4b0462e)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-21 15:29:01 +00:00
Miss Islington (bot)
48eb5c978e
gh-126780: Fix ntpath.normpath() for drive-relative paths (GH-126801)
(cherry picked from commit 60ec854bc2)

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
2024-11-21 15:10:12 +00:00
Serhiy Storchaka
6e5e7bc5f8
[3.13] gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730) (GH-127097)
It now returns multiple era description segments separated by semicolons.
Previously it only returned the first segment on platforms with Glibc.
(cherry picked from commit 4803cd0244)
2024-11-21 11:49:19 +00:00
Miss Islington (bot)
eaafc7857f
[3.13] gh-126997: Fix support of non-ASCII strings in pickletools (GH-127062) (GH-127094)
* 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).
(cherry picked from commit eaf2171082)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-21 11:40:52 +00:00
Miss Islington (bot)
746a0c5bc8
[3.13] GH-85168: Use filesystem encoding when converting to/from file URIs (GH-126852) (#127039)
GH-85168: Use filesystem encoding when converting to/from `file` URIs (GH-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.
(cherry picked from commit c9b399fbdb)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2024-11-20 20:10:29 +00:00
Miss Islington (bot)
40b9b506fb
[3.13] Run apt update before apt install git in autoconf CI job (GH-127070)
(cherry picked from commit 0af4ec30bd)

Co-authored-by: Zachary Ware <zach@python.org>
2024-11-20 19:44:17 +00:00
Miss Islington (bot)
fd9c2a3727
[3.13] Doc: C API: PyThreadState::on_delete was removed in v3.13 (GH-126536) (#127053)
Doc: C API: `PyThreadState::on_delete` was removed in v3.13 (GH-126536)
(cherry picked from commit 9bca3ef575)

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2024-11-20 08:51:19 +00:00
Miss Islington (bot)
bb98a0afd8
[3.13] gh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990) (GH-127018)
If PyObject_SetItem() fails in the `load_build()` function of _pickle.c, no DECREF for the `dict` variable.
(cherry picked from commit 29cbcbd73b)

Co-authored-by: Justin Applegate <70449145+Legoclones@users.noreply.github.com>
2024-11-19 20:19:39 +02:00
sobolevn
3fae84fe58
[3.13] gh-126980: Fix bytearray.__buffer__ crash on PyBUF_{READ,WRITE} (GH-126981) (#127023)
(cherry picked from commit 3932e1db53)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-19 20:37:53 +03:00
Miss Islington (bot)
dd222a4d47
[3.13] Update docs 'make serve' to suggest 'make htmllive' (GH-126969) (#127015)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-11-19 17:41:33 +02:00
Miss Islington (bot)
fd276ad328
[3.13] gh-126594: Fix typeobject.c wrap_buffer() cast (GH-126754) (#127004)
gh-126594: Fix typeobject.c wrap_buffer() cast (GH-126754)

Reject flags smaller than INT_MIN.

(cherry picked from commit 84f07c3a4c)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-11-19 08:38:06 +00:00
Sergey B Kirpichev
190d710e68
[3.13] Doc: Reorganize math module documentation (GH-126337) (#126998)
(cherry picked from commit ce453e6c2f)

Co-authored-by: Joseph Martinot-Lagarde <contrebasse@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-11-19 09:02:01 +01:00
Miss Islington (bot)
5457561452
[3.13] gh-126911: Update credits output (GH-126913) (#126973)
Co-authored-by: Stan U <89152624+StanFromIreland@users.noreply.github.com>
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 16:02:32 +00:00
Miss Islington (bot)
a7b44d6321
[3.13] gh-109413: Enable strict_optional = true for libregrtest/run_workers (GH-126855) (#126967)
gh-109413: Enable `strict_optional = true` for `libregrtest/run_workers` (GH-126855)
(cherry picked from commit a1d9c8aa80)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-11-18 14:50:31 +00:00
Petr Viktorin
da7e93de95
[3.13] gh-126789: Correct sysconfig test exclusions for iOS and Android. (GH-126941) (GH-126950)
(cherry picked from commit 3938fd60c0)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2024-11-18 14:57:58 +01:00
Miss Islington (bot)
1fbd84bf68
[3.13] gh-126909: Fix running xattr tests on systems with lower limits (GH-126930) (#126965)
gh-126909: Fix running xattr tests on systems with lower limits (GH-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.
(cherry picked from commit 2c0a21c1aa)

Co-authored-by: Michał Górny <mgorny@gentoo.org>
2024-11-18 13:33:53 +00:00
Miss Islington (bot)
c2c18acc3d
[3.13] gh-101955: Fix SystemError in possesive quantifier with alternative and group (GH-111362) (GH-126962)
(cherry picked from commit f9c5573ded)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-18 12:13:08 +00:00
Serhiy Storchaka
885386b4a2
[3.13] gh-67877: Fix memory leaks in terminated RE matching (GH-126840) (GH-126960)
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>
(cherry picked from commit 7538e7f569)
2024-11-18 11:26:45 +00:00
Miss Islington (bot)
2b2ad244c0
[3.13] gh-126167: Modify iOS Testbed to read arguments from Info.plist (GH-126169) (#126940)
gh-126167: Modify iOS Testbed to read arguments from Info.plist (GH-126169)
2024-11-18 08:50:54 +08:00
Miss Islington (bot)
9b06a8d2f5
[3.13] Docs: re-create pages for removed modules to document their removal. (GH-126622) (#126709)
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
2024-11-17 22:20:32 +02:00
Miss Islington (bot)
af35aa2880
[3.13] gh-124452: Fix header mismatches when folding/unfolding with email message (GH-125919) (#126917)
gh-124452: Fix header mismatches when folding/unfolding with email message (GH-125919)

The header-folder of the new email API has a long standing known buglet where
if the first token is longer than max_line_length, it puts that token on the next
line.  It turns out there is also a *parsing* bug when parsing such a header:
the space prefixing that first, non-empty line gets preserved and tacked on to
the start of the header value, which is not the expected behavior per the RFCs.
The bug arises from the fact that the parser assumed that there would be at
least one token on the line with the header, which is going to be true for
probably every email producer other than the python email library with its
folding buglet.  Clearly, though, this is a case that needs to be handled
correctly.  The fix is simple: strip the blanks off the start of the whole
value, not just the first physical line of the value.

(cherry picked from commit ed81971e6b)

Co-authored-by: RanKKI <hliu86.me@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-11-17 15:06:18 -05:00
Miss Islington (bot)
52efb95b45
[3.13] gh-126554: ctypes: Correctly handle NULL dlsym values (GH-126555) (#126861)
For dlsym(), a return value of NULL does not necessarily indicate
an error [1].

Therefore, to avoid using stale (or NULL) dlerror() values, we must:

 1. clear the previous error state by calling dlerror()
 2. call dlsym()
 3. call dlerror()

If the return value of dlerror() is not NULL, an error occured.

In ctypes we choose to treat a NULL return value from dlsym()
as a "not found" error. This is the same as the fallback
message we use on Windows, Cygwin or when getting/formatting
the error reason fails.

[1]: https://man7.org/linux/man-pages/man3/dlsym.3.html

(cherry picked from commit 8717f792f7)

Signed-off-by: Georgios Alexopoulos <grgalex@ba.uoa.gr>
Co-authored-by: George Alexopoulos <giorgosalexo0@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-11-17 18:59:13 +01:00
Miss Islington (bot)
ec9cbcb86b
[3.13] GH-126789: fix some sysconfig data on late site initializations
Co-authored-by: Filipe Laíns 🇵🇸 <lains@riseup.net>
2024-11-17 00:32:22 +00:00
Miss Islington (bot)
d74f1f477a
[3.13] gh-126476: Raise IllegalMonthError for calendar.formatmonth() when the input month is not correct (GH-126484) (GH-126879)
gh-126476: Raise IllegalMonthError for calendar.formatmonth() when the input month is not correct (GH-126484)
(cherry picked from commit 3be7498d24)

Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2024-11-15 15:20:25 -08:00
Miss Islington (bot)
c8962104f2
[3.13] Added a warning to the urljoin docs, indicating that it is not safe to use with attacker controlled URLs (GH-126659) (#126888)
Added a warning to the urljoin docs, indicating that it is not safe to use with attacker controlled URLs (GH-126659)

This was flagged to me at a party today by someone who works in red-teaming as a frequently encountered footgun. Documenting the potentially unexpected behavior seemed like a good place to start.
(cherry picked from commit d6bcc154e9)

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2024-11-15 23:15:27 +00:00
Miss Islington (bot)
7be8743bd1
[3.13] gh-71936: Fix race condition in multiprocessing.Pool (GH-124973) (GH-126869)
Proxes of shared objects register a Finalizer in BaseProxy._incref(), and it
will call BaseProxy._decref() when it is GCed. This may cause a race condition
with Pool(maxtasksperchild=None) on Windows.

A connection would be closed and raised TypeError when a GC occurs between
_ConnectionBase._check_writable() and _ConnectionBase._send_bytes() in
_ConnectionBase.send() in the second or later task, and a new object
is allocated that shares the id() of a previously deleted one.

Instead of using the id() of the token (or the proxy), use a unique,
non-reusable number.

(cherry picked from commit ba088c8f9c)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Akinori Hattori <hattya@gmail.com>
2024-11-15 14:05:14 +00:00
Peter Bierma
ecda3ae2a5
[3.13] gh-126312: Don't traverse frozen objects on the free-threaded build (GH-126338) (#126866)
* Fix merge conflicts.

* [3.13] gh-126312: Don't traverse frozen objects on the free-threaded build (GH-126338)

Also, _PyGC_Freeze() no longer freezes unreachable objects.

(cherry picked from commit d4c72fed8c)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>

---------

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2024-11-15 14:46:00 +01:00
Miss Islington (bot)
3227680d2d
gh-118973: Add _tkinter to freethreaded MSI (GH-126768)
(cherry picked from commit 9332a6f825)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-11-15 13:10:07 +00:00
Miss Islington (bot)
9a02690513
[3.13] gh-123832: Adjust socket.getaddrinfo docs for better POSIX compliance (GH-126182) (GH-126825)
gh-123832: Adjust `socket.getaddrinfo` docs for better POSIX compliance (GH-126182)

* gh-123832: Adjust `socket.getaddrinfo` docs for better POSIX compliance

This changes nothing changes for CPython supported platforms,
but hints how to deal with platforms that stick to the letter of
the spec.
It also marks `socket.getaddrinfo` as a wrapper around `getaddrinfo(3)`;
specifically, workarounds to make the function work consistently across
platforms are out of scope in its code.

Include wording similar to the POSIX's “by providing options and by
limiting the returned information”, which IMO suggests that the
hints limit the resulting list compared to the defaults, *but* can
be interpreted differently. Details are added in a note.

Specifically say that this wraps the underlying C function. So, the
details are in OS docs. The “full range of results” bit goes away.

Use `AF_UNSPEC` rather than zero for the *family* default, although
I don't think a system where it's nonzero would be very usable.

Suggest setting proto and/or type (with examples, as the appropriate
values aren't obvious). Say why you probably want to do that that
on all systems; mention the behavior on the “letter of the spec”
systems.

Suggest that the results should be tried in order, which is,
AFAIK best practice -- see RFC 6724 section 2, and its predecessor
from 2003 (which are specific to IP, but indicate how people use this):

> Well-behaved applications SHOULD iterate through the list of
> addresses returned from `getaddrinfo()` until they find a working address.

(cherry picked from commit ff0ef0a54b)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-11-15 14:06:57 +01:00
Tomas R.
1c158705f1
[3.13] gh-126413: Add translation tests for getopt and optparse (GH-126698) (GH-126755)
(cherry picked from commit dff074d144)
2024-11-15 13:06:54 +02:00
Miss Islington (bot)
cb07c44e19
[3.13] GH-126766: url2pathname(): handle empty authority section. (GH-126767) (#126836)
GH-126766: `url2pathname()`: handle empty authority section. (GH-126767)

Discard two leading slashes from the beginning of a `file:` URI if they
introduce an empty authority section. As a result, file URIs like
`///etc/hosts` are correctly parsed as `/etc/hosts`.
(cherry picked from commit cae9d9d20f)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2024-11-14 23:52:36 +00:00
Miss Islington (bot)
bf40fdbff1
[3.13] gh-126807: pygettext: Do not attempt to extract messages from function definitions. (GH-126808) (GH-126846)
Fixes a bug where pygettext would attempt
to extract a message from a code like this:

def _(x): pass

This is because pygettext only looks at one
token at a time and '_(x)' looks like a
function call.

However, since 'x' is not a string literal,
it would erroneously issue a warning.
(cherry picked from commit 9a456383be)

Co-authored-by: Tomas R <tomas.roun8@gmail.com>
2024-11-14 22:43:33 +00:00