Commit graph

51641 commits

Author SHA1 Message Date
Miss Islington (bot)
e5ab9e3740
[3.12] gh-112064: Fix incorrect handling of negative read sizes in HTTPResponse.read() (GH-128270) (#129396)
gh-112064: Fix incorrect handling of negative read sizes in `HTTPResponse.read()` (GH-128270)

The parameter `amt` of `HTTPResponse.read()`, which could be a negative integer,
has not been handled before and led to waiting for the connection to close
for `keep-alive connections`. Now, this has been fixed, and passing negative values
to `HTTPResponse().read()` works the same as passing `None` value.
(cherry picked from commit 4d0d24f6e3)

Co-authored-by: Yury Manushkin <manushkin@gmail.com>
2025-01-28 11:54:27 +00:00
Miss Islington (bot)
2df8b395b0
[3.12] gh-119511: Fix a potential denial of service in imaplib (GH-119514) (GH-129356)
gh-119511: Fix a potential denial of service in imaplib (GH-119514)

The IMAP4 client could consume an arbitrary amount of memory when trying
to connect to a malicious server, because it read a "literal" data with a
single read(size) call, and BufferedReader.read() allocates the bytes
object of the specified size before reading. Now the IMAP4 client reads data
by chunks, therefore the amount of used memory is limited by the
amount of the data actually been sent by the server.
(cherry picked from commit 735f25c5e3)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-01-27 14:06:14 -08:00
Miss Islington (bot)
0d53d7afd5
[3.12] gh-71339: Use new assertion methods in test_idle (GH-129314) (#129315)
Revise 10 tests in 7 files, with 1 test split into 2.
(cherry picked from commit 1499f66c4c)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-01-26 05:33:44 -05:00
Miss Islington (bot)
c17d30bf34
[3.12] gh-58956: Set f_trace on frames with breakpoints after setting a new breakpoint (GH-124454) (#125549)
* gh-58956: Set f_trace on frames with breakpoints after setting a new breakpoint (GH-124454)
(cherry picked from commit 12eaadc0ad)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2025-01-25 15:12:19 -05:00
Miss Islington (bot)
e94939cedb
[3.12] gh-128479: fix asyncio staggered race leaking tasks, and logging unhandled exception.append exception (GH-128475) (#129228)
gh-128479: fix asyncio staggered race leaking tasks, and logging unhandled exception.append exception (GH-128475)
(cherry picked from commit ec91e1c276)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-01-23 22:16:21 +01:00
Victor Stinner
bb7c54d5ba
[3.12] gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191) (#129217) (#129221)
[3.13] gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191) (#129217)

gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191)

Support calling PyTraceMalloc_Track() and PyTraceMalloc_Untrack()
during late Python finalization.

* Call _PyTraceMalloc_Fini() later in Python finalization.
* Test also PyTraceMalloc_Untrack() without the GIL
* PyTraceMalloc_Untrack() now gets the GIL.
* Test also PyTraceMalloc_Untrack() in test_tracemalloc_track_race().

(cherry picked from commit 46c7e13c05)
(cherry picked from commit e3b3e01d6a)
2025-01-23 13:29:46 +00:00
Pablo Galindo Salgado
9ed04d9516
[3.12] gh-124363: Treat debug expressions in f-string as raw strings (GH-128399) (#129190)
(cherry picked from commit 60a3a0dd6f)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-01-22 18:08:58 +00:00
Pablo Galindo Salgado
e577ff4ce4
[3.12] gh-129093: Fix f-string debug text sometimes getting cut off when expression contains ! (#129164) 2025-01-22 00:47:20 +00:00
Thomas Grainger
bc214545f9
[3.12] gh-128588: fix refcycles in eager task creation and remove eager tasks optimization that missed and introduced incorrect cancellations (#129063) (#128586)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-21 11:11:39 +05:30
Miss Islington (bot)
03bce18992
[3.12] GH-128131: Completely support random read access of uncompressed unencrypted files in ZipFile (GH-128143) (#129092)
GH-128131: Completely support random read access of uncompressed unencrypted files in ZipFile (GH-128143)
(cherry picked from commit dda02eb7be)

Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.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>
2025-01-20 20:40:28 +00:00
Serhiy Storchaka
032058cb62
[3.12] gh-71339: Add additional assertion methods in test.support (GH-128707) (GH-128815) (GH-129059)
Add a mix-in class ExtraAssertions containing the following methods:

* assertHasAttr() and assertNotHasAttr()
* assertIsSubclass() and assertNotIsSubclass()
* assertStartsWith() and assertNotStartsWith()
* assertEndsWith() and assertNotEndsWith()

(cherry picked from commit c6a566e47b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 06cad77a5b)
2025-01-20 12:06:02 +00:00
Miss Islington (bot)
b8170e5884
[3.12] gh-80222: Fix email address header folding with long quoted-string (GH-122753) (#129008)
gh-80222: Fix email address header folding with long quoted-string (GH-122753)

Email generators using email.policy.default could incorrectly omit the
quote ('"') characters from a quoted-string during header refolding,
leading to invalid address headers and enabling header spoofing. This
change restores the quote characters on a bare-quoted-string as the
header is refolded, and escapes backslash and quote chars in the string.
(cherry picked from commit 5aaf416858)

Co-authored-by: Mike Edmunds <medmunds@gmail.com>
2025-01-19 16:07:39 -05:00
Victor Stinner
fceb8c31dd
[3.12] gh-111495: Add more tests on PyEval C APIs (#122789) (#128987) (#129023)
* Add Lib/test/test_capi/test_eval.py
* Add Modules/_testlimitedcapi/eval.c

(cherry picked from commit bf8b374639)

* gh-111495: Fix refleaks in test_capi.test_eval tests (#122851)

(cherry picked from commit b4a316087c)
(cherry picked from commit 430ccbc009)
2025-01-19 13:51:53 +00:00
Victor Stinner
6df22cbf60
[3.12] gh-128679: Fix tracemalloc.stop() race conditions (#128897) (#129022)
[3.13] gh-128679: Fix tracemalloc.stop() race conditions (#128897)

tracemalloc_alloc(), tracemalloc_realloc(), PyTraceMalloc_Track(),
PyTraceMalloc_Untrack() and _PyTraceMalloc_TraceRef() now check
tracemalloc_config.tracing after calling TABLES_LOCK().

_PyTraceMalloc_Stop() now protects more code with TABLES_LOCK(),
especially setting tracemalloc_config.tracing to 1.

Add a test using PyTraceMalloc_Track() to test tracemalloc.stop()
race condition.

Call _PyTraceMalloc_Init() at Python startup.

(cherry picked from commit 6b47499510)
2025-01-19 13:24:14 +00:00
Serhiy Storchaka
83de72e5ec
[3.12] gh-128911: Add tests on the PyImport C API (GH-128915) (GH-128960) (#128989)
* Add Modules/_testlimitedcapi/import.c
* Add Lib/test/test_capi/test_import.py
* Remove _testcapi.check_pyimport_addmodule(): tests already covered
  by newly added tests.
(cherry picked from commit 34ded1a1a1)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit d95ba9fa11)
2025-01-19 14:21:55 +01:00
Tian Gao
6d638c2655
[3.12] gh-128991: Release the enter frame reference within bdb callba… (#129003)
[3.12] gh-128991: Release the enter frame reference within bdb callback (GH-128992)

* Release the enter frame reference within bdb callback

* 📜🤖 Added by blurb_it.

---------

(cherry picked from commit 61b35f74aa)
2025-01-18 17:21:34 -05:00
Bénédikt Tran
fbbef609d1
[3.12] gh-127637: add tests for dis command-line interface (#127759) (#127780) 2025-01-18 12:01:56 +01:00
Miss Islington (bot)
405f6d72bb
[3.12] gh-128961: Fix exhausted array iterator crash in __setstate__() (GH-128962) (#128977)
(cherry picked from commit 4dade055f4)

Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
2025-01-18 10:14:07 +00:00
Miss Islington (bot)
8a8f5d636d
[3.12] gh-128916: Do not set SO_REUSEPORT on non-AF_INET* sockets (GH-128933) (#128970)
gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets (GH-128933)

* gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets

Do not attempt to set ``SO_REUSEPORT`` on sockets of address familifies other
than ``AF_INET`` and ``AF_INET6``, as it is meaningless with these address
families, and the call with fail with Linux kernel 6.12.9 and newer.

* Apply suggestions from code review



---------
(cherry picked from commit 3829104ab4)

Co-authored-by: Michał Górny <mgorny@gentoo.org>
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2025-01-18 01:06:45 +00:00
Tian Gao
f45da82c11
[3.12] gh-58956: Fix a frame refleak in bdb (GH-128190) (#128953)
* [3.12] gh-58956: Fix a frame refleak in bdb (GH-128190)
(cherry picked from commit 767c89ba7c)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2025-01-17 14:19:37 -05:00
Miss Islington (bot)
45b89bf0da
[3.12] gh-128816: Fix warnings in test_doctest (GH-128817) (GH-128871)
* Fix a deprecation warning for using importlib.resources.abc.ResourceReader.
* Fix an import warning when importing readline (if it has not yet been imported).
(cherry picked from commit 599be687ec)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2025-01-16 09:09:13 +00:00
Bénédikt Tran
6c9b7e591b
[3.12] gh-128833: Patch test_embed.test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE on Windows (#128860)
Hotfix for `test_embed`
2025-01-15 14:22:45 +01:00
Miss Islington (bot)
febe67b993
[3.12] gh-109959: Skip test_glob.test_selflink() flaky test (GH-128812) (#128834)
gh-109959: Skip test_glob.test_selflink() flaky test (GH-128812)
(cherry picked from commit 1153e66e20)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-14 15:32:11 +00:00
Miss Islington (bot)
e7400d7877
[3.12] gh-125997: Increase test coverage for time.sleep() (GH-128751) (#128795)
gh-125997: Increase test coverage for `time.sleep()` (GH-128751)

- Add tests for durations of invalid types.
- Add tests for `int` and `float` durations, including signed zeroes durations.
- Add tests for nonzero very small durations and durations close to the clock resolution.

---------
(cherry picked from commit b70a567575)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-13 17:16:25 +00:00
Miss Islington (bot)
552b2a0f6e
[3.12] Explicitly import urllib.error in urllib.robotparser (GH-128737) (#128794)
Explicitly import `urllib.error` in `urllib.robotparser` (GH-128737)
(cherry picked from commit 53e8942e69)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-01-13 16:32:38 +00:00
Miss Islington (bot)
ca5ff6b40c
[3.12] gh-128562: Fix generation of the tkinter widget names (GH-128604) (GH-128792)
There were possible conflicts if the widget class name ends with a digit.
(cherry picked from commit da8825ea95)

Co-authored-by: Zhikang Yan <2951256653@qq.com>
2025-01-13 18:23:53 +02:00
Miss Islington (bot)
4facd7d119
[3.12] gh-128078: Clear exception in anext before calling _PyGen_SetStopIterationValue (GH-128780) (#128784)
gh-128078: Clear exception in `anext` before calling `_PyGen_SetStopIterationValue` (GH-128780)
(cherry picked from commit 76ffaef729)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-13 18:45:20 +05:30
Miss Islington (bot)
b773f591a8
[3.12] gh-128731: Explicitly close socket on error in robotparser.RobotFileParser.read() (GH-128733) (GH-128756)
(cherry picked from commit 5e65a1acc0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-01-12 13:34:24 +00:00
Serhiy Storchaka
c20c551ce3
[3.12] gh-128734: Explicitly close sockets in urllib tests (GH-128735) (GH-128750)
(cherry picked from commit 5ace71713b)
2025-01-12 11:30:07 +00:00
Miss Islington (bot)
07a65cdcc5
[3.12] gh-128302: Fix bugs in xml.dom.xmlbuilder (GH-128284) (#128583)
gh-128302: Fix bugs in xml.dom.xmlbuilder (GH-128284)

* Allow DOMParser.parse() to correctly handle DOMInputSource instances
  that only have a systemId attribute set.
* Fix DOMEntityResolver.resolveEntity(), which was broken by the
  Python 3.0 transition.
* Add Lib/test/test_xml_dom_xmlbuilder.py with few tests.
(cherry picked from commit 6ea04da270)

Co-authored-by: Stephen Morton <git@tungol.org>
2025-01-11 13:30:29 +02:00
Miss Islington (bot)
4c130c9238
[3.12] gh-128615: Cover pickling of ParamSpecArgs and ParamSpecKwargs (GH-128616) (#128626)
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-01-08 12:25:59 +00:00
Miss Islington (bot)
b69b9da9b5
[3.12] gh-41872: Fix quick extraction of module docstrings from a file in pydoc (GH-127520) (GH-128621)
It now supports docstrings with single quotes, escape sequences,
raw string literals, and other Python syntax.

(cherry picked from commit 474e419792)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-01-08 14:21:30 +02:00
Miss Islington (bot)
d8890fb82d
[3.12] gh-128613: Increase typing.Concatenate coverage (GH-128614) (#128624)
gh-128613: Increase `typing.Concatenate` coverage (GH-128614)
(cherry picked from commit eb26e17069)

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-01-08 12:20:00 +00:00
Erlend E. Aasland
b46addafb1
[3.12] gh-123085: Remove double 'import os' added by PR #124021 (#128600)
gh-123085: Remove double 'import os' added by PR #124021
2025-01-07 19:23:17 -05:00
Miss Islington (bot)
dae5b16bb3
[3.12] gh-98188: Fix EmailMessage.get_payload to decode data when CTE value has extra text (GH-127547) (#128529)
gh-98188: Fix EmailMessage.get_payload to decode data when CTE value has extra text (GH-127547)

Up to this point message handling has been very strict with regards to content encoding values: mixed case was accepted, but trailing blanks or other text would cause decoding failure, even if the first token was a valid encoding.  By Postel's Rule we should go ahead and decode as long as we can recognize that first token.  We have not thought of any security or backward compatibility concerns with this fix.

This fix does introduce a new technique/pattern to the Message code: we look to see if the header has a 'cte' attribute, and if so we use that.  This effectively promotes the header API exposed by HeaderRegistry to an API that any header parser "should" support.  This seems like a reasonable thing to do.  It is not, however, a requirement, as the string value of the header is still used if there is no cte attribute.

The full fix (ignore any trailing blanks or blank-separated trailing text) applies only to the non-compat32 API.  compat32 is only fixed to the extent that it now ignores trailing spaces.  Note that the HeaderRegistry parsing still records a HeaderDefect if there is extra text.

(cherry picked from commit a62ba52f14)

Co-authored-by: RanKKI <hliu86.me@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-01-07 12:44:56 -05:00
Miss Islington (bot)
e758eb3018
[3.12] gh-123085: _compile_importlib: Avoid copying sources before compilation (GH-124131) (GH-128581)
gh-123085: _compile_importlib: Avoid copying sources before compilation (GH-124131)
(cherry picked from commit 42c8b0556c)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2025-01-07 12:28:03 +01:00
Miss Islington (bot)
f9aac4a76d
[3.12] gh-128519: Align the docstring of untokenize() to match the docs (GH-128521) (#128532)
(cherry picked from commit aef52ca8b3)

Co-authored-by: Tomas R <tomas.roun8@gmail.com>
2025-01-06 08:59:24 +00:00
Jason R. Coombs
d712ece43f
[3.12] gh-123085: Fix issue in inferred caller when resources package has no source (GH-123102) (#124021)
gh-123085: Fix issue in inferred caller when resources package has no source.

From importlib_resources 6.4.3 (python/importlib_resourcesGH-314).
(cherry picked from commit a53812df12)
2025-01-05 16:53:55 -05:00
Miss Islington (bot)
06e4173393
[3.12] gh-127553: Remove outdated TODO comment in _pydatetime (GH-127564) (#128501)
(cherry picked from commit e8b6b39ff7)

Co-authored-by: Beomsoo Kim <beoms424@gmail.com>
2025-01-04 22:55:24 +00:00
Miss Islington (bot)
e44045924d
[3.12] gh-127903: Fix a crash on debug builds when calling Objects/unicodeobject::_copy_characters (GH-127876) (#128459)
gh-127903: Fix a crash on debug builds when calling `Objects/unicodeobject::_copy_characters`` (GH-127876)
(cherry picked from commit 46cb6340d7)

Co-authored-by: Alexander Shadchin <shadchin@yandex-team.com>
2025-01-03 21:21:08 +02:00
Serhiy Storchaka
7ce09fc93b
[3.12] gh-128014: Fix passing default='' to the tkinter method wm_iconbitmap() (GH-128015) (GH-128420)
(cherry picked from commit 58e9f95c4a)

Co-authored-by: Zhikang Yan <2951256653@qq.com>
2025-01-02 16:21:00 +00:00
Miss Islington (bot)
ca017a171a
[3.12] gh-88834: Unify the instance check for typing.Union and types.UnionType (GH-128363) (GH-128371)
Union now uses the instance checks against its parameters instead of
the subclass checks.
(cherry picked from commit b2ac70a62a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-12-31 08:19:45 +00:00
Miss Islington (bot)
fcc9bc49c4
[3.12] gh-128342: Specify timeout unit in subprocess docstrings (GH-128343) (#128366)
gh-128342: Specify timeout unit in subprocess docstrings (GH-128343)

Specify timeout unit (seconds) in subprocess docstrings
(cherry picked from commit dafe7a4463)

Co-authored-by: n-l-i <57808975+n-l-i@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-12-30 13:14:27 -08:00
Miss Islington (bot)
be7314ffac
[3.12] gh-127586: multiprocessing.Pool does not properly restore blocked signals (try 2) (GH-128011) (#128299)
gh-127586: multiprocessing.Pool does not properly restore blocked signals (try 2) (GH-128011)

Correct pthread_sigmask in resource_tracker to restore old signals

Using SIG_UNBLOCK to remove blocked "ignored signals" may accidentally
cause side effects if the calling parent already had said signals
blocked to begin with and did not intend to unblock them when
creating a pool. Use SIG_SETMASK instead with the previous mask of
blocked signals to restore the original blocked set.
(cherry picked from commit aeb9b65aa2)

Co-authored-by: Stephen Hansen <stephen.paul.hansen@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-12-29 11:02:59 -08:00
Miss Islington (bot)
3a726be127
[3.12] Mention loop_factory argument in docstring for asyncio.run() (GH-128288) (#128292)
Mention loop_factory argument in docstring for asyncio.run() (GH-128288)
(cherry picked from commit 0b5f1fae57)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2024-12-27 14:15:40 +00:00
Shantanu
82dbfbfec9
[3.12] gh-127537: Add __class_getitem__ to the python implementation of functools.partial (#127537) (#128282)
gh-127537: Add __class_getitem__ to the python implementation of functools.partial (#127537)

(cherry picked from commit 401bba6b58)

Co-authored-by: CF Bolz-Tereick <cfbolz@gmx.de>
2024-12-27 01:25:07 +00:00
Miss Islington (bot)
fe41537c60
[3.12] gh-127847: Fix position in the special-cased zipfile seek (GH-127856) (#128226)
gh-127847: Fix position in the special-cased zipfile seek (GH-127856)

---------
(cherry picked from commit 7ed6c5c696)

Co-authored-by: Dima Ryazanov <dima@bucket.xxx>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-12-24 16:15:45 +00:00
Miss Islington (bot)
f65ac86ca1
[3.12] gh-128049: Fix type confusion bug with the return value of a custom ExceptionGroup split function (GH-128079) (#128140)
gh-128049: Fix type confusion bug with the return value of a custom ExceptionGroup split function (GH-128079)
(cherry picked from commit 3879ca0100)

Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
2024-12-20 20:19:12 +00:00
Miss Islington (bot)
23e8fc2775
[3.12] gh-128116: Skip test_socket VSOCK testStream() on PermissionError (GH-128120) (#128124)
gh-128116: Skip test_socket VSOCK testStream() on PermissionError (GH-128120)
(cherry picked from commit cbfe3023e4)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-20 13:39:26 +00:00
Miss Islington (bot)
6ffa564446
[3.12] gh-126742: Avoid checking for library filename in test_ctypes (GH-128034) (#128057)
gh-126742: Avoid checking for library filename in test_ctypes (GH-128034)

Avoid checking for library filename in `dlerror()` error messages of test_ctypes.
(cherry picked from commit 335e24fb0a)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-12-18 08:45:34 +00:00