Commit graph

120057 commits

Author SHA1 Message Date
Miss Islington (bot)
91399c3984
[3.12] gh-127303: Add docs for token.EXACT_TOKEN_TYPES (GH-127304) (#127391)
gh-127303: Add docs for token.EXACT_TOKEN_TYPES (GH-127304)

---------

(cherry picked from commit dd3a87d2a8)

Co-authored-by: Илья Любавский <100635212+lubaskinc0de@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-11-29 09:22:27 +00:00
Miss Islington (bot)
7d175caf21
[3.12] gh-127190: Fix local_setattro() error handling (GH-127366) (#127368)
gh-127190: Fix local_setattro() error handling (GH-127366)

Don't make the assumption that the 'name' argument is a string. Use
repr() to format the 'name' argument instead.
(cherry picked from commit 20657fbdb1)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-28 17:32:50 +00:00
Victor Stinner
f4c9f39165
[3.12] gh-123967: Fix faulthandler for trampoline frames (#127329) (#127363)
gh-123967: Fix faulthandler for trampoline frames (#127329)

If the top-most frame is a trampoline frame, skip it.

(cherry picked from commit 58e334e143)
2024-11-28 13:57:35 +00:00
Miss Islington (bot)
c3bb32de9d
[3.12] gh-124008: Fix calculation of the number of written bytes for the Windows console (GH-124059) (GH-127326)
Since MultiByteToWideChar()/WideCharToMultiByte() is not reversible if
the data contains invalid UTF-8 sequences, use binary search to
calculate the number of written bytes from the number of written
characters.

Also fix writing incomplete UTF-8 sequences.

Also fix handling of memory allocation failures.
(cherry picked from commit 3cf83d91a5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-27 16:00:30 +02:00
Miss Islington (bot)
97ed21636c
[3.12] gh-109746: Fix race condition in test_start_new_thread_failed (GH-127299) (GH-127324)
(cherry picked from commit 83926d3b4c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-27 12:22:32 +00:00
Yuki Kobayashi
16e899d589
[3.12] gh-101100: Fix sphinx warnings in howto/* (GH-127084) (#127311) 2024-11-27 11:46:42 +02:00
Miss Islington (bot)
08531ac83f
[3.12] gh-127183: Add _ctypes.CopyComPointer tests (GH-127184) (GH-127252)
gh-127183: Add `_ctypes.CopyComPointer` tests (GH-127184)

* Make `create_shelllink_persist` top level function.

* Add `CopyComPointerTests`.

* Add more tests.

* Update tests.

* Add assertions for `Release`'s return value.
(cherry picked from commit c7f1e3e150)

Co-authored-by: Jun Komoda <45822440+junkmd@users.noreply.github.com>
2024-11-26 11:13:29 +01:00
Miss Islington (bot)
619037af1c
[3.12] gh-127265: Remove single quotes from 'arrow's in tutorial/errors.rst (GH-127268)
(cherry picked from commit 26ff32b305)

Co-authored-by: funkyrailroad <funkyrailroad@users.noreply.github.com>
2024-11-25 21:42:34 +00:00
Rafael Fontenelle
3806772b3d
[3.12] Fix a few typos found in the docs (GH-127126) (GH-127185)
(cherry picked from commit 39e60aeb38)
2024-11-25 11:48:00 -08:00
Miss Islington (bot)
a4d6b905dd
[3.12] gh-127182: Fix io.StringIO.__setstate__ crash when None is the first value (GH-127219) (#127263)
gh-127182: Fix `io.StringIO.__setstate__` crash when `None` is the first value (GH-127219)
(cherry picked from commit a2ee899682)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-25 17:51:21 +00:00
Miss Islington (bot)
f7e587d15c
[3.12] gh-126384: Add tests to verify the behavior of basic COM methods. (GH-126610) (GH-127160)
(cherry picked from commit 7725c0371a)

Co-authored-by: Jun Komoda <45822440+junkmd@users.noreply.github.com>
2024-11-25 13:18:35 +01:00
Yuki Kobayashi
7e901cbdd8
[3.12] gh-101100: Fix sphinx warnings of removed opcodes (GH-127222) (#127240) 2024-11-25 10:51:48 +02:00
Miss Islington (bot)
5bfacd26e8
[3.12] gh-127217: Fix pathname2url() for paths starting with multiple slashes on Posix (GH-127218) (GH-127231)
(cherry picked from commit 97b2ceaaaf)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-24 20:13:23 +02:00
Miss Islington (bot)
b52ab48a10
[3.12] Improve pathname2url() and url2pathname() docs (GH-127125) (#127233)
Improve `pathname2url()` and `url2pathname()` docs (GH-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.
(cherry picked from commit 307c633586)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2024-11-24 17:48:12 +00:00
Miss Islington (bot)
e26ba9670f
[3.12] Fix "useable" typo in docs (GH-127200) (#127206)
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 16:45:47 -05:00
Miss Islington (bot)
6d2821c833
[3.12] Doc: C API: Fix Py_NewInterpreterFromConfig example code (GH-126667) (#127202)
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:55:55 +00:00
Serhiy Storchaka
f1e7424802
[3.12] gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761) (GH-127173)
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:56:39 +00:00
Serhiy Storchaka
29648980d4
[3.12] gh-127001: Fix PATHEXT issues in shutil.which() on Windows (GH-127035) (GH-127158)
* 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)
2024-11-22 16:33:50 +00:00
Miss Islington (bot)
32bc8e83db
[3.12] GH-122679: Add register() to argparse docs (GH-126939) (GH-127148)
(cherry picked from commit fcfdb55465)

Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
2024-11-22 14:13:43 +00:00
Jun Komoda
caad9047cb
[3.12] gh-127082: Replace "Windows only" with the availability: Windows in ctypes doc (GH-127099) (#127145)
(cherry picked from commit 3c770e3f09)
2024-11-22 14:08:37 +01:00
Miss Islington (bot)
c470e822bf
[3.12] GH-127078: url2pathname(): handle extra slash before UNC drive in URL path (GH-127132) (#127136)
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:51 +00:00
Miss Islington (bot)
4b705f50d1
[3.12] GH-126766: url2pathname(): handle 'localhost' authority (GH-127129) (#127131)
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:46 +00:00
Serhiy Storchaka
4b4e0dbdf4
[3.12] gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730) (GH-127098)
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:44:37 +00:00
Miss Islington (bot)
d997be0510
[3.12] gh-126997: Fix support of non-ASCII strings in pickletools (GH-127062) (GH-127095)
* 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:32:16 +00:00
Miss Islington (bot)
512a5bdb2f
[3.12] Run apt update before apt install git in autoconf CI job (GH-127071)
(cherry picked from commit 0af4ec30bd)

Co-authored-by: Zachary Ware <zach@python.org>
2024-11-20 19:37:24 +00:00
Miss Islington (bot)
b33c37aa8c
[3.12] gh-126991: Add tests for unpickling bad object state (GH-127031) (GH-127064)
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-20 15:49:58 +00:00
Miss Islington (bot)
7735f58ea5
[3.12] GH-85168: Use filesystem encoding when converting to/from file URIs (GH-126852) (#127040)
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-19 21:55:10 +00:00
Miss Islington (bot)
153221a1d0
[3.12] gh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990) (GH-127019)
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:18 +02:00
Miss Islington (bot)
cb98122df2
[3.12] Update docs 'make serve' to suggest 'make htmllive' (GH-126969) (#127016)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-11-19 17:41:41 +02:00
Russell Keith-Magee
1f911ba706
[3.12] gh-126789: Correct sysconfig test exclusions for iOS and Android. (GH-126941) (GH-126959)
(cherry picked from commit 3938fd60c0)
2024-11-19 11:01:54 +01:00
Miss Islington (bot)
9345dc165c
[3.12] gh-126594: Fix typeobject.c wrap_buffer() cast (GH-126754) (#127005)
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:33:18 +00:00
Miss Islington (bot)
126acc1bb0
[3.12] gh-126911: Update credits output (GH-126913) (#126974)
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 15:58:22 +00:00
Miss Islington (bot)
fd241d64c1
[3.12] gh-126909: Fix running xattr tests on systems with lower limits (GH-126930) (#126964)
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:22:58 +00:00
Miss Islington (bot)
06dc4bd073
[3.12] gh-101955: Fix SystemError in possesive quantifier with alternative and group (GH-111362) (GH-126963)
(cherry picked from commit f9c5573ded)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-18 12:03:19 +00:00
Serhiy Storchaka
8eb25faed7
[3.12] gh-67877: Fix memory leaks in terminated RE matching (GH-126840) (GH-126961)
If SRE(match) function terminates abruptly, either because of a signal
or because memory allocation fails, allocated SRE_REPEAT blocks might
be never released.

(cherry picked from commit 7538e7f569)
2024-11-18 11:24:13 +00:00
Miss Islington (bot)
9d986d9477
[3.12] gh-124452: Fix header mismatches when folding/unfolding with email message (GH-125919) (#126916)
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:12:29 -05:00
Miss Islington (bot)
50e42b9980
[3.12] GH-126789: fix some sysconfig data on late site initializations
Co-authored-by: Filipe Laíns 🇵🇸 <lains@riseup.net>
2024-11-17 00:26:59 +00:00
Miss Islington (bot)
cdc1dff33f
[3.12] gh-126476: Raise IllegalMonthError for calendar.formatmonth() when the input month is not correct (GH-126484) (GH-126878)
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:10 -08:00
Miss Islington (bot)
797a6327cc
[3.12] Added a warning to the urljoin docs, indicating that it is not safe to use with attacker controlled URLs (GH-126659) (#126889)
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:17:37 +00:00
Miss Islington (bot)
d0d892f7a3
[3.12] gh-71936: Fix race condition in multiprocessing.Pool (GH-124973) (GH-126870)
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:04:35 +00:00
Miss Islington (bot)
ef0a0059e1
[3.12] gh-123832: Adjust socket.getaddrinfo docs for better POSIX compliance (GH-126182) (GH-126824)
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:07:04 +01:00
Tomas R.
ad4f8debda
[3.12] gh-126413: Add translation tests for getopt and optparse (GH-126698) (GH-126756)
(cherry picked from commit dff074d144)
2024-11-15 13:07:16 +02:00
Miss Islington (bot)
04f38bb775
[3.12] GH-126766: url2pathname(): handle empty authority section. (GH-126767) (#126837)
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:46 +00:00
Miss Islington (bot)
306db142c2
[3.12] gh-126807: pygettext: Do not attempt to extract messages from function definitions. (GH-126808) (GH-126847)
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:35:35 +00:00
Miss Islington (bot)
d79acd96e0
[3.12] Document that return-less user-defined functions return None (GH-126769) (#126823)
Document that return-less user-defined functions return None (GH-126769)
(cherry picked from commit e0692f1165)

Co-authored-by: John Marshall <jmarshall@hey.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-11-14 10:46:26 +01:00
Miss Islington (bot)
3ed99b3eb3
[3.12] gh-126731: Update outdated project information in pprint.pp doc (GH-126732) (#126819)
gh-126731: Update outdated project information in `pprint.pp` doc (GH-126732)
(cherry picked from commit 6a93a1adbb)

Co-authored-by: Wulian <xiguawulian@gmail.com>
2024-11-14 05:08:18 +00:00
Miss Islington (bot)
49e212a929
[3.12] gh-124448: Update bundled Tcl/Tk in macOS installer to 8.6.15. (GH-125800)
(cherry picked from commit fc9e6bf53d)

Co-authored-by: Ned Deily <nad@python.org>
2024-11-14 00:06:14 -05:00
Ned Batchelder
73dedbd223
[3.12] Docs: re-create pages for removed modules to document their removal, based on GH-126622 (#126781)
[3.12] Docs: re-create pages for removed modules to document their removal, based on #126622
2024-11-13 19:02:09 -05:00
Stéphane Bidoul
87b3318229
[3.12] gh-126188: Update bundled pip to 24.3.1 (gh-126805) (gh-126813)
Update bundled pip to 24.3.1
(cherry picked from commit f6b0361c17)
2024-11-13 23:42:54 +00:00
Miss Islington (bot)
df59b64589
[3.12] GH-126606: don't write incomplete pyc files (GH-126627) (GH-126810)
GH-126606: don't write incomplete pyc files (GH-126627)
(cherry picked from commit c695e37a3f)

Co-authored-by: CF Bolz-Tereick <cfbolz@gmx.de>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Brett Cannon <brett@python.org>
2024-11-13 14:49:47 -08:00