Commit graph

49879 commits

Author SHA1 Message Date
Miss Islington (bot)
22eb97cf9b
[3.11] gh-88118: Fix some test_multiprocessing flakiness. (GH-116434) (GH-116441)
Fix some test_multiprocessing flakiness.

Potentially introduced by https://github.com/python/cpython/pull/25845

not joining that thread likely leads to recently observed "environment
changed" logically passing but overall failing tests seen on some
buildbots similar to:

```
1 test altered the execution environment (env changed):
    test.test_multiprocessing_fork.test_processes

2 re-run tests:
    test.test_multiprocessing_fork.test_processes
    test.test_multiprocessing_forkserver.test_processes
```
(cherry picked from commit ea1803e608)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-03-06 22:20:37 +00:00
Sebastian Pipping
fc9da96274
[3.11] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (#116268)
Allow controlling Expat >=2.6.0 reparse deferral (CVE-2023-52425) by adding five new methods:

- `xml.etree.ElementTree.XMLParser.flush`
- `xml.etree.ElementTree.XMLPullParser.flush`
- `xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`
- `xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`
- `xml.sax.expatreader.ExpatParser.flush`

Based on the "flush" idea from #115138 (comment) .

- Please treat as a security fix related to CVE-2023-52425.

(cherry picked from commit 6a95676)
(cherry picked from commit 73807eb)
(cherry picked from commit eda2963)

---------

Includes code suggested-by: Snild Dolkow <snild@sony.com>
and by core dev Serhiy Storchaka.
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-03-06 14:17:02 -08:00
Miss Islington (bot)
26f7956f8f
[3.11] gh-116143: Fix race condition in pydoc _start_server (GH-116144) (#116416)
gh-116143: Fix race condition in pydoc _start_server (GH-116144)
(cherry picked from commit 02ee475ee3)

Co-authored-by: Itamar Oren <itamarost@gmail.com>
2024-03-06 15:07:08 +00:00
Terry Jan Reedy
f4672e2569
[3.11] chore: fix typos (GH-116345) (#116375)
Co-authored-by: cui fliter <imcusg@gmail.com>
(cherry picked from commit e7ba6e9dbe)
2024-03-05 20:33:59 +00:00
Miss Islington (bot)
fa670a59ba
[3.11] gh-74668: Fix support of bytes in urllib.parse.parse_qsl() (GH-115771) (GH-116367)
urllib.parse functions parse_qs() and parse_qsl() now support bytes
arguments containing raw and percent-encoded non-ASCII data.
(cherry picked from commit bdba8ef42b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-05 17:52:03 +00:00
Miss Islington (bot)
c75df4b13a
[3.11] gh-76511: Fix email.Message.as_string() for non-ASCII message with ASCII charset (GH-116125) (GH-116365)
(cherry picked from commit f97f25ef5d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-05 17:32:30 +00:00
Miss Islington (bot)
f187da5b59
[3.11] gh-116325: Raise SyntaxError rather than IndexError on ForwardRef with empty string arg (GH-116341) (#116348)
gh-116325: Raise `SyntaxError` rather than `IndexError` on ForwardRef with empty string arg (GH-116341)
(cherry picked from commit a29998a06b)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-05 10:15:54 +00:00
Nikita Sobolev
8bfbeeb0a1
[3.11] gh-112281: Allow Union with unhashable Annotated metadata (GH-112283) (#116288)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-03-03 20:20:01 +00:00
Miss Islington (bot)
d3756edbc4
[3.11] gh-115809: Improve TimedRotatingFileHandler.getFilesToDelete() (GH-115812) (GH-116262)
Improve algorithm for computing which rolled-over log files to delete
in logging.TimedRotatingFileHandler. It is now reliable for handlers
without namer and with arbitrary deterministic namer that leaves
the datetime part in the file name unmodified.
(cherry picked from commit 87faec28c7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-03 08:01:52 +00:00
Serhiy Storchaka
9485566096
[3.11] gh-114494: Change logging docstring to bool for exec_info (GH-114558) (GH-116242)
(cherry picked from commit 07236f5b39)

Co-authored-by: Tristan Pank <tristanpank@gmail.com>
2024-03-02 15:40:17 +02:00
Miss Islington (bot)
c36393690f
[3.11] gh-88352: Fix logging.TimedRotatingFileHandler (GH-116191) (GH-116209)
* Do not overwrite already rolled over files. It happened at midnight or
  during the DST change and caused the loss of data.
* computeRollover() now always return the timestamp larger than the
  specified time.
* Fix computation of the rollover time during the DST change.
(cherry picked from commit fee86fd9a4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-01 18:41:58 +02:00
Miss Islington (bot)
726c1170e8
[3.11] gh-101293: Fix support of custom callables and types in inspect.Signature.from_callable() (GH-115530) (GH-116197)
Support callables with the __call__() method and types with
__new__() and __init__() methods set to class methods, static
methods, bound methods, partial functions, and other types of
methods and descriptors.

Add tests for numerous types of callables and descriptors.
(cherry picked from commit 59167c962e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-01 12:55:14 +00:00
Tian Gao
d3282f5411
[3.11] gh-87115: Set __main__.__spec__ to None in pdb (GH-116141) (#116155)
* gh-87115: Set `__main__.__spec__` to `None` in pdb (#116141)

(cherry picked from commit ccfc042bbf)

* [3.11] gh-87115: Set `__main__.__spec__` to `None` in pdb (GH-116141)
(cherry picked from commit ccfc042bbf)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2024-02-29 23:24:32 +00:00
Miss Islington (bot)
8643cfd918
[3.11] gh-72463: Fix ctypes/test_loading.py so that test_find reports skipped (GH-18312) (GH-116137)
(cherry picked from commit 04d1000071)

Co-authored-by: Michael Felt <aixtools@users.noreply.github.com>
2024-02-29 19:48:38 +00:00
Miss Islington (bot)
9db482c7d9
[3.11] gh-116103: Prevent error in WindowsLoadTracker.__del__ on permission error (GH-116105) (GH-116121)
gh-116103: Prevent error in WindowsLoadTracker.__del__ on permission error (GH-116105)
(cherry picked from commit 186fa93876)


gh-116103: Prevent error in WindowsLoadTracker.__del__ if there was a permission error

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-02-29 14:44:55 +00:00
Miss Islington (bot)
e7dc85308f
[3.11] gh-115197: Stop resolving host in urllib.request proxy bypass (GH-115210)
gh-115197: Stop resolving host in urllib.request proxy bypass (GH-115210)

Use of a proxy is intended to defer DNS for the hosts to the proxy itself, rather than a potential for information leak of the host doing DNS resolution itself for any reason.  Proxy bypass lists are strictly name based.  Most implementations of proxy support agree.
(cherry picked from commit c43b26d02e)

Co-authored-by: Weii Wang <weii.wang@canonical.com>
2024-02-28 20:53:00 +00:00
Irit Katriel
99ab0d49e2
[3.11] gh-116034: fix location info on the error of a failed assertion (#116052) 2024-02-28 19:12:16 +00:00
Miss Islington (bot)
f225740211
[3.11] doc: Use super() in subclassed JSONEncoder examples (GH-115565) (GH-116046)
doc: Use super() in subclassed JSONEncoder examples (GH-115565)

Replace calls to `json.JSONEncoder.default(self, obj)`
by `super().default(obj)` within the examples of the documentation.
(cherry picked from commit 647053fed1)

Co-authored-by: Jan Max Meyer <jmm@phorward.de>
2024-02-28 14:08:40 +00:00
Serhiy Storchaka
becc61596f
[3.11] gh-115961: Improve tests for compressed file-like objects (GH-115963) (GH-116039)
* Increase coverage for compressed file-like objects initialized with a
  file name, an open file object, a file object opened by file
  descriptor, and a file-like object without name and mode attributes
  (io.BytesIO)
* Increase coverage for name, fileno(), mode, readable(), writable(),
  seekable() in different modes and states
* No longer skip tests with bytes names
* Test objects implementing the path protocol, not just pathlib.Path.
(cherry picked from commit e72576c48b)
2024-02-28 09:38:39 +00:00
Miss Islington (bot)
4007086019
[3.11] gh-112006: Fix inspect.unwrap() for types where __wrapped__ is a data descriptor (GH-115540) (GH-115965)
(cherry picked from commit 68c79d21fa)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-27 18:35:55 +00:00
Miss Islington (bot)
eb13ac66c4
[3.11] bpo-43952: Fix multiprocessing Listener authkey bug (GH-25845) (GH-115994)
Listener.accept() no longer hangs when authkey is an empty bytes object.
(cherry picked from commit 686ec17f50)

Co-authored-by: Miguel Brito <5544985+miguendes@users.noreply.github.com>
2024-02-27 16:14:01 +00:00
Miss Islington (bot)
c562f5a1e2
[3.11] bpo-44865: Fix yet one missing translations in argparse (GH-27668) (GH-115975)
(cherry picked from commit 6087315926)

Co-authored-by: Jérémie Detrey <jdetrey@users.noreply.github.com>
2024-02-26 23:14:32 +00:00
Serhiy Storchaka
f8a6a1c5c3
[3.11] gh-77956: Add the words 'default' and 'version' help text localizable (GH-12711) (GH-115968)
(cherry picked from commit da382aaf52)

Co-authored-by: paul.j3
Co-authored-by: Emmanuel Arias <eamanu@yaerobi.com>
Co-authored-by: Jérémie Detrey <jdetrey@users.noreply.github.com>
2024-02-26 21:36:57 +00:00
Miss Islington (bot)
46f821d62b
[3.11] gh-114763: Protect lazy loading modules from attribute access races (GH-114781) (GH-115871)
gh-114763: Protect lazy loading modules from attribute access races (GH-114781)

Setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. Now that is protected by a lock.
(cherry picked from commit 200271c61d)

Co-authored-by: Chris Markiewicz <effigies@gmail.com>
2024-02-26 20:50:55 +00:00
Alex Waygood
a30a1e7a49
[3.11] gh-115881: Ensure ast.parse() parses conditional context managers even with low feature_version passed (#115920) (#115960) 2024-02-26 16:27:51 +00:00
Miss Islington (bot)
35a43d4394
[3.11] gh-115823: Calculate correctly error locations when dealing with implicit encodings (GH-115824) (#115950)
gh-115823: Calculate correctly error locations when dealing with implicit encodings (GH-115824)
(cherry picked from commit 015b97d19a)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2024-02-26 16:08:37 +00:00
Serhiy Storchaka
f2b1f6b828
[3.11] gh-115886: Handle embedded null characters in shared memory name (GH-115887) (GH-115907)
shm_open() and shm_unlink() now check for embedded null characters in
the name and raise an error instead of silently truncating it.
(cherry picked from commit 79811ededd)
2024-02-25 11:12:07 +00:00
Miss Islington (bot)
c6455ff0fd
[3.11] bpo-14322: added test case for invalid update to hmac (GH-26636) (#115905)
Co-authored-by: Arjun <ccldarjun@icloud.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-02-25 10:52:55 +00:00
Miss Islington (bot)
a4a28e50fe
[3.11] gh-67044: Always quote or escape \r and \n in csv.writer() (GH-115741) (GH-115867)
(cherry picked from commit c688c0f130)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-23 20:43:53 +00:00
Miss Islington (bot)
f7052d530c
[3.11] gh-88516: show file proxy icon in IDLE editor windows on macOS (GH-112894) (#115841)
The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.

Don't use both the long and short names in the window title.
The behaviour of other editors (such as Text Editor) is to show
only the short name with the proxy icon.

(cherry picked from commit b48101864c)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-02-23 02:38:49 +00:00
Miss Islington (bot)
301f166310
[3.11] gh-93205: When rotating logs with no namer specified, match whole extension (GH-93224) (GH-115785)
(cherry picked from commit 113687a838)

Co-authored-by: Gabriele Catania <gabriele.ctn@gmail.com>
2024-02-21 21:44:06 +00:00
Miss Islington (bot)
a27c540d20
[3.11] gh-96310: Fix a traceback in argparse when all options in a mutually exclusive group are suppressed (GH-96311) (GH-115768)
Reproducer depends on terminal size - the traceback occurs when there's
an option long enough so the usage line doesn't fit the terminal width.
Option order is also important for reproducibility.

Excluding empty groups (with all options suppressed) from inserts
fixes the problem.
(cherry picked from commit 5f7df88821)

Co-authored-by: Daniel Mach <daniel.mach@suse.com>
2024-02-21 18:20:08 +02:00
Serhiy Storchaka
9068c8c614
[3.11] gh-115712: Support CSV dialects with delimiter=' ' and skipinitialspace=True (GH-115721) (GH-115729) (GH-115738)
(cherry picked from commit 5ea86f496a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
csv.writer() now quotes empty fields if delimiter is a space and
skipinitialspace is true and raises exception if quoting is not possible.
(cherry picked from commit 937d282150)
2024-02-20 19:09:10 +00:00
Miss Islington (bot)
142711a31d
[3.11] gh-86291: linecache: get module name from __spec__ if available (GH-22908) (GH-115732)
This allows getting source code for the __main__ module when a custom
loader is used.
(cherry picked from commit e976baba99)

Co-authored-by: Eugene Toder <eltoder@users.noreply.github.com>
2024-02-20 18:18:16 +00:00
Miss Islington (bot)
aff083e8ee
[3.11] Add missed stream argument (GH-111775) (#115717)
Add missed `stream` argument (GH-111775)

* Add missed `stream` argument

* Add news
(cherry picked from commit 1ff6c1416b)

Co-authored-by: Alexander Shadchin <shadchin@yandex-team.com>
2024-02-20 11:36:59 -05:00
Miss Islington (bot)
b3384af464
[3.11] gh-115539: Allow enum.Flag to have None members (GH-115636) (GH-115695)
gh-115539: Allow enum.Flag to have None members (GH-115636)
(cherry picked from commit c2cb31bbe1)

Co-authored-by: Jason Zhang <yurenzhang2017@gmail.com>
2024-02-19 16:18:30 -08:00
Miss Islington (bot)
c02b7ae4dd
[3.11] gh-60346: Improve handling single-dash options in ArgumentParser.parse_known_args() (GH-114180) (GH-115674)
(cherry picked from commit e47ecbd042)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-19 18:20:51 +00:00
Serhiy Storchaka
e1994c43c0
[3.11] Fix test_compile with -O mode (GH-115346) (GH-115673)
(cherry picked from commit 7b25a82e83)
2024-02-19 18:06:13 +00:00
Miss Islington (bot)
0bb94f49e3
[3.11] gh-115341: Fix loading unit tests with doctests in -OO mode (GH-115342) (GH-115672)
(cherry picked from commit 872cc9957a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-19 17:54:59 +00:00
Miss Islington (bot)
55b9633316
[3.11] Fix test_py_compile with -O mode (GH-115345) (GH-115670)
(cherry picked from commit 07ef9d86a5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-19 17:45:56 +00:00
Miss Islington (bot)
91262320da
[3.11] gh-108303: Move Lib/test/sortperf.py to Tools/scripts (GH-114687) (#115626)
gh-108303: Move `Lib/test/sortperf.py` to `Tools/scripts` (GH-114687)
(cherry picked from commit f9154f8f23)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-02-18 07:43:36 +00:00
Serhiy Storchaka
5dac9c53cd
[3.11] gh-115618: Remove improper Py_XDECREFs in property methods (GH-115619) (GH-115621)
(cherry picked from commit 090dd21ab9)
2024-02-17 21:47:32 +00:00
Miss Islington (bot)
cd0a071fdd
[3.11] gh-115596: Fix ProgramPriorityTests in test_os permanently changing the process priority (GH-115610) (GH-115617)
(cherry picked from commit 90dd653a61)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
2024-02-17 19:14:41 +02:00
Kirill Podoprigora
ee3d8dcb00
[3.11] gh-107155: Fix help() for lambda function with return annotation (GH-115613)
(cherry picked from commit b9a9e3dd62)
2024-02-17 17:39:48 +02:00
Miss Islington (bot)
a23aecc737
[3.11] Fix ProgramPriorityTests on FreeBSD with high nice value (GH-100145) (GH-115615)
It expects priority to be capped with 19, which is the cap for Linux,
but for FreeBSD the cap is 20 and the test fails under the similar
conditions. Tweak the condition to cover FreeBSD as well.
(cherry picked from commit 437924465d)

Co-authored-by: Dmitry Marakasov <amdmi3@amdmi3.ru>
2024-02-17 15:38:38 +00:00
Serhiy Storchaka
6fbc61070f
[3.11] gh-100985: Consistently wrap IPv6 IP address during CONNECT (GH-100986) (GH-115606)
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
(cherry picked from commit 465db27cb9)

Co-authored-by: Derek Higgins <derekh@redhat.com>
2024-02-17 14:15:21 +00:00
Serhiy Storchaka
51b974b0ab
[3.11] gh-96497: Mangle name before symtable lookup in 'symtable_extend_namedexpr_scope' (GH-96561) (GH-115604)
(cherry picked from commit 664965a1c1)

Co-authored-by: wookie184 <wookie1840@gmail.com>
2024-02-17 13:13:26 +00:00
Miss Islington (bot)
4077f1445c
[3.11] gh-101384: Add socket timeout to ThreadedVSOCKSocketStreamTest and skip it on WSL (GH-101419) (GH-115586)
(cherry picked from commit 9fd420f53d)

Co-authored-by: Peter Jiping Xie <peter.jp.xie@gmail.com>
2024-02-17 15:02:47 +02:00
Miss Islington (bot)
70754d21c2
[3.11] gh-100884: email/_header_value_parser: don't encode list separators (GH-100885) (GH-115593)
ListSeparator should not be encoded. This could happen when a long line
pushes its separator to the next line, which would have been encoded.
(cherry picked from commit 09fab93c3d)

Co-authored-by: Thomas Weißschuh <thomas@t-8ch.de>
2024-02-17 15:01:02 +02:00
Miss Islington (bot)
a5eaa14584
[3.11] gh-95782: Fix io.BufferedReader.tell() etc. being able to return offsets < 0 (GH-99709) (GH-115600)
lseek() always returns 0 for character pseudo-devices like
`/dev/urandom` (for other non-regular files, e.g. `/dev/stdin`, it
always returns -1, to which CPython reacts by raising appropriate
exceptions). They are thus technically seekable despite not having seek
semantics.

When calling read() on e.g. an instance of `io.BufferedReader` that
wraps such a file, `BufferedReader` reads ahead, filling its buffer,
creating a discrepancy between the number of bytes read and the internal
`tell()` always returning 0, which previously resulted in e.g.
`BufferedReader.tell()` or `BufferedReader.seek()` being able to return
positions < 0 even though these are supposed to be always >= 0.

Invariably keep the return value non-negative by returning
max(former_return_value, 0) instead, and add some corresponding tests.
(cherry picked from commit 26800cf25a)

Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
2024-02-17 14:55:43 +02:00