Commit graph

30272 commits

Author SHA1 Message Date
Bénédikt Tran
718886f6c6
[3.13] gh-140530: fix a reference leak in an error path for raise exc from cause (GH-140908) (#141283)
gh-140530: fix a reference leak in an error path for `raise exc from cause` (#140908)

Fix a reference leak in `raise E from T` when `T` is an exception
subtype for which `T.__new__` does not return an exception instance.

(cherry picked from commit 0c77e7c23b)
2025-11-09 15:57:26 +01:00
Bénédikt Tran
873f0d023c
[3.13] gh-100218: correctly set errno when socket.if_{nametoindex,indextoname} raise OSError (GH-140905) (#141285)
Previously, socket.if_nametoindex() and socket.if_indextoname() could raise
an `OSError` with a `None` errno. Now, the errno from libc is propagated.

(cherry picked from commit 3ce2d57b2f)
2025-11-09 13:31:49 +00:00
Stan Ulbrych
0923704b49
[3.13] gh-139246: zero-width word paste can be wrong in default repl (GH-139254) (GH-141166)
(cherry picked from commit 4e6dba0ef7)

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: yihong <zouzou0208@gmail.com>
Co-authored-by: grayjk <grayjk@gmail.com>
2025-11-07 13:51:03 +01:00
Miss Islington (bot)
353bfc813b
[3.13] gh-141141: Make base64.b85decode() thread safe (GH-141149) (GH-141185)
(cherry picked from commit a7bf27f7f5)

Co-authored-by: Benel Tayar <86257734+beneltayar@users.noreply.github.com>
2025-11-07 11:10:21 +00:00
Miss Islington (bot)
dcd2dbaf36
[3.13] gh-140734: fix off-by-one error when comparing to _SUN_PATH_MAX (GH-140903) (#141182)
gh-140734: fix off-by-one error when comparing to `_SUN_PATH_MAX` (GH-140903)

The limit includes a NULL terminator.
(cherry picked from commit 9a19900673)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-07 10:18:06 +00:00
Stan Ulbrych
f1a93727c4
[3.13] gh-140939: Fix memory leak in _PyBytes_FormatEx error path (GH-140957) (#141155)
(cherry picked from commit d6c89a2df2)
2025-11-06 16:16:43 +00:00
Victor Stinner
43882c7c4e
[3.13] gh-140815: Fix faulthandler for invalid/freed frame (#140921) (#140985)
gh-140815: Fix faulthandler for invalid/freed frame (#140921)

faulthandler now detects if a frame or a code object is invalid or
freed.

Add helper functions:

* _PyCode_SafeAddr2Line()
* _PyFrame_SafeGetCode()
* _PyFrame_SafeGetLasti()

_PyMem_IsPtrFreed() now detects pointers in [-0xff, 0xff] range
as freed.

(cherry picked from commit a84181c31b)
2025-11-05 18:39:28 +01:00
Miss Islington (bot)
ee894d2abb
[3.13] gh-140797: Forbid capturing groups in re.Scanner lexicon patterns (GH-140944) (GH-140983)
(cherry picked from commit fa9c3eefd4)

Co-authored-by: Abhishek Tiwari <Abhi210@users.noreply.github.com>
2025-11-04 11:17:29 +00:00
Jiucheng(Oliver)
10af8404b4
[3.13] gh-135307: Fix email error when policy max_line_length is set to 0 or None (GH-135367) (#140917)
[3.13] gh-135307: Fix email error when policy max_line_length is set to 0 or None (GH-135367)
(cherry picked from commit 6d45cd8dbb)

Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
RDM: Like the change made in a earlier PR to the folder, we can/must use 'maxlen' as a stand in for 'unlimited' when computing line lengths when max_line_length is 0 or None; otherwise the computation results in a traceback.
2025-11-02 15:20:29 -05:00
Sebastian Pipping
bc36bd1786
[3.13] gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (GH-139234) (#139367)
* gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (#139234)

Expose the XML Expat 2.7.2 mitigation APIs to disallow use of
disproportional amounts of dynamic memory from within an Expat
parser (see CVE-2025-59375 for instance).

The exposed APIs are available on Expat parsers, that is,
parsers created by `xml.parsers.expat.ParserCreate()`, as:

- `parser.SetAllocTrackerActivationThreshold(threshold)`, and
- `parser.SetAllocTrackerMaximumAmplification(max_factor)`.

(cherry picked from commit f04bea44c3)
(cherry picked from commit 68a1778b77)
2025-11-02 12:39:11 +00:00
Miss Islington (bot)
9a3a147988
[3.13] gh-140874: Upgrade bundled pip to 25.3 (GH-140876) (gh-140880)
* gh-140874: Upgrade bundled pip to 25.3 (GH-140876)

Upgrade bundled pip to 25.3
(cherry picked from commit d440a0f96c)

Co-authored-by: Damian Shaw <damian.peter.shaw@gmail.com>

* Update Misc/NEWS.d/next/Library/2025-11-01-00-36-14.gh-issue-140874.eAWt3K.rst

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

---------

Co-authored-by: Damian Shaw <damian.peter.shaw@gmail.com>
Co-authored-by: Paul Moore <p.f.moore@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-01 12:42:15 +00:00
Łukasz Langa
9ab89c026a
[3.13] gh-136065: Fix quadratic complexity in os.path.expandvars() (GH-134952) (GH-140845)
(cherry picked from commit f029e8db62)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-10-31 17:58:09 +01:00
Miss Islington (bot)
0329bd11c7
[3.13] gh-137836: Support more RAWTEXT and PLAINTEXT elements in HTMLParser (GH-137837) (GH-140842)
* the "plaintext" element
* the RAWTEXT elements "xmp", "iframe", "noembed" and "noframes"
* optionally RAWTEXT (if scripting=True) element "noscript"
(cherry picked from commit a17c57eee5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-10-31 16:08:42 +00:00
Mikhail Efimov
eec9257aa5
[3.13] gh-140551: Fix dict crash if clear is called at lookup stage (GH-140558) (#140744)
* gh-140551: Fix `dict` crash if `clear` is called at `lookup` stage (#140558)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2025-10-30 22:36:49 +05:30
Miss Islington (bot)
32c3dcc7a4
[3.13] gh-138162: Fix logging.LoggerAdapter with merge_extra=True and without the extra argument (GH-140511) (GH-140785)
(cherry picked from commit 327dbbedff)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-10-30 11:31:54 +00:00
Mikhail Efimov
08cacb2a14
[3.13] gh-140576: Fixed crash produced by lexer in case of dedented zero byte (GH-140583) (#140762) 2025-10-29 14:33:55 +00:00
Miss Islington (bot)
62a3b6b0d9
[3.13] gh-140082: Forward colorizing from libregrtest to unittest (GH-140083) (#140755)
gh-140082: Forward colorizing from libregrtest to unittest (GH-140083)

libregrtest redirects test output to a file as part of its operation.
When `unittest` checks to see if it should colorize with
`isatty(sys.stdout)` that fails resulting in no colorizing of the
unittest output.

Update `libregrtest` to set `FORCE_COLOR=1` when redirecting test output
so that unittest will do color printing.
(cherry picked from commit 6ff62ac4fb)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-29 12:55:54 +00:00
Cody Maloney
a1a71efa6e
[3.13] gh-140607: Validate returned byte count in RawIOBase.read (GH-140611) (#140730)
* [3.13] gh-140607: Validate returned byte count in RawIOBase.read (GH-140611)

While `RawIOBase.readinto` should return a count of bytes between 0 and
the length of the given buffer, it is not required to. Add validation
inside RawIOBase.read() that the returned byte count is valid.
(cherry picked from commit 0f0a362768)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>

* fixup: Use older attribute name

---------

Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-29 13:31:57 +01:00
Miss Islington (bot)
bec053c184
[3.13] GH-140590: Fix setstate for functools.partial C-module (GH-140671) (#140699)
GH-140590: Fix setstate for functools.partial C-module (GH-140671)

(cherry picked from commit d26686a7f8)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
2025-10-28 18:14:14 +05:30
Miss Islington (bot)
9c8eade20c
[3.13] gh-140634: Fix a reference counting bug in os.sched_param.__reduce__() (GH-140667) (GH-140686)
(cherry picked from commit 364ae607d8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-10-27 20:05:10 +00:00
Shamil
fd6df66624
[3.13] gh-140301: Fix memory leak in subinterpreter PyConfig cleanup (GH-140303) (#140684)
[3.13] gh-140301: Fix memory leak in subinterpreter `PyConfig` cleanup (GH-140303)
(cherry picked from commit a615fb49c9)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-27 19:42:13 +00:00
Victor Stinner
ec5f5418f9
[3.13] gh-140487: Fix Py_RETURN_NOTIMPLEMENTED in limited C API 3.11 (GH-140636) (GH-140670)
Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE have already been
fixed by commit 9258f3da91 (issue gh-134989).

(cherry picked from commit c636477523)
2025-10-27 14:43:59 +01:00
Miss Islington (bot)
0e3b47b839
[3.13] gh-140633: AppleFrameworkLoader: Ignore AttributeError when setting __file__ (GH-140635) (GH-140659)
(cherry picked from commit 3416e7c8dc)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-10-27 14:08:09 +01:00
Sebastian Pipping
7abbf51839
[3.13] gh-140593: Fix a memory leak in function my_ElementDeclHandler of pyexpat (GH-140602) (#140630)
[3.13] gh-140593: Fix a memory leak in function `my_ElementDeclHandler` of `pyexpat` (GH-140602)

Ensure that the memory allocated for the content model
passed to `my_ElementDeclHandler` is freed in all error
paths.

(cherry picked from commit e34a5e3304)
2025-10-26 15:22:20 +00:00
Miss Islington (bot)
0f0ca07d79
[3.13] gh-140482: Preserve and restore stty echo as a test environment (GH-140519) (#140563)
gh-140482: Preserve and restore `stty echo` as a test environment (GH-140519)
(cherry picked from commit b3c713a0af)


gh-140482: Restore `stty echo` as a test environment

Co-authored-by: Barry Warsaw <barry@python.org>
2025-10-24 18:30:59 +00:00
Stan Ulbrych
1cc2c954d6
[3.13] gh-140471: Fix buffer overflow in AST node initialization with malformed _fields (GH-140506) (#140510)
(cherry picked from commit 95953b692d)
2025-10-24 00:38:02 +01:00
Miss Islington (bot)
640bc258c1
[3.13] gh-140474: Fix memory leak in array.array (GH-140478) (GH-140499)
gh-140474: Fix memory leak in `array.array` (GH-140478)
(cherry picked from commit aa9d0a61d5)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-23 12:18:01 +00:00
Peter Bierma
69230d1c56
[3.13] gh-140406: Fix memory leak upon __hash__ returning a non-integer (GH-140411) (GH-140441)
* gh-140406: Fix memory leak upon `__hash__` returning a non-integer (GH-140411)

(cherry picked from commit 71db05a12d)
2025-10-22 01:07:32 +00:00
Serhiy Storchaka
d7473f7a47
[3.13] gh-140306: Fix memory leaks in cross-interpreter data handling (GH-140307) (GH-140357)
(cherry picked from commit f9323213c9)

Co-authored-by: Shamil <ashm.tech@proton.me>
2025-10-20 10:13:15 +00:00
Serhiy Storchaka
0231a391f9
[3.13] gh-140272: Fix memory leak in _gdbm.gdbm.clear() (GH-140274) (GH-140289)
(cherry picked from commit f937468e7c)

Co-authored-by: Shamil <ashm.tech@proton.me>
2025-10-18 11:00:10 +00:00
Miss Islington (bot)
0760a572f7
[3.13] gh-138859: Account for ParamSpec defaults that are not lists … (GH-138868) (#140208)
gh-138859: Account for `ParamSpec` defaults that are not lists … (GH-138868)
(cherry picked from commit 379fd020a0)

Co-authored-by: bzoracler <50305397+bzoracler@users.noreply.github.com>
2025-10-16 13:26:24 -07:00
Miss Islington (bot)
f09a6a2fc8
[3.13] gh-140041: Fix import of ctypes on Android and Cygwin when ABI flags are present (GH-140178) (#140181)
Use sysconfig to determine the full name of libpython, rather than hardcoding
a library name that doesn't have ABI flags.
(cherry picked from commit 7f371ed84b)

Co-authored-by: Malcolm Smith <smith@chaquo.com>
2025-10-15 22:03:25 +00:00
Miss Islington (bot)
77976761ba
[3.13] gh-138993: Dedent credits text (GH-138994) (#140087)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-15 14:05:53 +03:00
Thomas Wouters
e40f1619ec Python 3.13.9
-----BEGIN PGP SIGNATURE-----
 
 iQKTBAABCgB9FiEEcWlgX2LHUTVtBUomqCHmgOX6YwUFAmjuVaJfFIAAAAAALgAo
 aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDcx
 Njk2MDVGNjJDNzUxMzU2RDA1NEEyNkE4MjFFNjgwRTVGQTYzMDUACgkQqCHmgOX6
 YwXJow//cfFrVV9JbaBvZhMPnVAdjPfLd1sskCzTEvM/SkNmUqqmjUGh6TgCf9uZ
 ujSDe8sZ+ihDSPMFEWg7uQQULn2qKioCvGptVMHIWIKaWjutb3qZJBfXKIFxpvr4
 jZyLnRsTVQZ3RllPGjlb0WzBrazmCLmVOsZyHCAmRpeSPPE77KJXn9dsz5PlA+KH
 8n2LsvuG2hqF46NBZu0ro43d6rX16TrBI7CGMZQMTMkDGe75vIQrhk/2Ek66UZtA
 6Y5grca1vsnSEPNaVXLKpC+Ndosf6ziI23YLoAnsE8q15lEsEwAiS8Rx2rqiWVgb
 MwrUccveyiqm5/bv0v+MHXOXzuipEchR/YfdyJPBm1JyeOEvYX+Zsp0sMe5nVIV8
 WHWgnrb0A0pIbCLL5LqoPdCrksOq23NYkE/ayvHmaOhFsQ62vedts/RFLpnyPlVl
 9iY/XE098MUvngsDkkCVqNwkZNYWymqnDRm2hqPWNqQlDSCPGhpR4dcPLr0FW8Ji
 iJUdYJ0Q5h6YJOMLZyfRkqlPUxay7PSw6+PjaKyHChpAAPlhqPqjsYcLSjxRJ3QX
 R5A7V1gavRV0opHnQzDoQxMacjmCA3ELnAXqBly8YyjOB+OuRg5UP1xDlwYkaHF4
 mwMMw731XM98MXphu4Q0PW594TQplLbDsdpmcWimFtAJu2NVW4U=
 =hm/l
 -----END PGP SIGNATURE-----

Python 3.13.9
2025-10-14 20:33:45 +02:00
Serhiy Storchaka
92f7965cf6
[3.13] gh-139640: Fix swallowing syntax warnings in different modules (GH-139755) (GH-140119)
Revert GH-131993.

Fix swallowing some syntax warnings in different modules if they accidentally
have the same message and are emitted from the same line.

Fix duplicated warnings in the "finally" block.

(cherry picked from commit 279db6bede)
2025-10-14 15:46:11 +00:00
Stan Ulbrych
c5ec267311
[3.13] gh-101828: Fix jisx0213 codecs removing null characters (gh-139340) (gh-140112)
* [3.13] gh-101828: Fix `jisx0213` codecs removing null characters (gh-139340)
(cherry picked from commit 87eadce3e0)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

* Accidentally removed line
2025-10-14 14:48:29 +00:00
Thomas Wouters
8183fa5e3f Python 3.13.9 2025-10-14 15:52:31 +02:00
Miss Islington (bot)
bc2c8d748c [3.13] gh-139783: Fix inspect.getsourcelines() for the case when a decorator is followed by a comment or an empty line (GH-139836) (GH-139890)
(cherry picked from commit f4104f5d74)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-10-14 15:47:20 +02:00
Sergey B Kirpichev
bfb9639352
[3.13] gh-102431: Clarify constraints on operands of Decimal logical operations (GH-102836) (#140106)
* [3.13] gh-102431: Clarify constraints on operands of Decimal logical operations (GH-102836)

Sync C/Python implementation of the decimal: logical_ops for contexts.
(cherry picked from commit 6ecf77dbde)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-10-14 15:45:02 +02:00
Miss Islington (bot)
7e40d94725
[3.13] gh-70765: Remove unnecessary extra backtick from Changelog entry (GH-140071) (#140101)
gh-70765: Remove unnecessary extra backtick from Changelog entry (GH-140071)
(cherry picked from commit f70082b477)

Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>
2025-10-14 11:16:02 +00:00
Mikhail Efimov
cbcee9a0f0
[3.13] gh-140000: Traverse name attribute for TypeVar, TypeVarTuple, TypeAliasType, ParamSpec (GH-140016) (#140073)
Correct traversing name attribute for TypeVar, TypeVarTuple, TypeAliasType, ParamSpec
2025-10-13 20:02:32 -07:00
Miss Islington (bot)
cbb415e992
[3.13] gh-139905: Provide suggestion in error message if Generic.__init_subclass__ was not called (GH-139943) (#139956)
gh-139905: Provide suggestion in error message if `Generic.__init_subclass__` was not called (GH-139943)
(cherry picked from commit 5776d0d2e0)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-11 15:36:44 +00:00
Miss Islington (bot)
6a9908ee94
[3.13] gh-96491: Deduplicate version in IDLE shell title (GH-139841) (#139932)
gh-96491: Deduplicate version in IDLE shell title (GH-139841)

Saving to a file added both the filename and repeated the version.
---------
(cherry picked from commit d4e5802588)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-10-11 02:00:21 +00:00
Miss Islington (bot)
aee27d9d19
[3.13] gh-139783: Fix inspect.getsourcelines() for the case when a decorator is followed by a comment or an empty line (GH-139836) (GH-139890)
(cherry picked from commit f4104f5d74)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-10-10 21:26:36 +00:00
Miss Islington (bot)
b1bc743d36
[3.13] gh-139065: Fix trailing space before long word in textwrap (GH-139070) (GH-139903)
Fix trailing space before a wrapped long word if the line length with
a space is exactly "width".
(cherry picked from commit 1c598e0436)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-10-10 13:51:41 +00:00
Łukasz Langa
94ff4d4eb4
[3.13] gh-139391: properly handle signal.signal() in UnixConsole when called from a non-main thread (GH-139392) (#139861)
(cherry picked from commit b8c8b8f1d3)

Co-authored-by: yihong <zouzou0208@gmail.com>
2025-10-09 23:09:23 +05:30
Miss Islington (bot)
54f9613a37
[3.13] gh-139845: do not print twice in default asyncio REPL (GH-139846) (#139860)
gh-139845: do not print twice in default asyncio REPL (GH-139846)
(cherry picked from commit a310b3a99d)

Co-authored-by: yihong <zouzou0208@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-09 21:38:04 +05:30
Sam Gross
16d2e97cf3
[3.13] gh-137400: Fix thread-safety issues when profiling all threads (gh-137518) (gh-137733)
There were a few thread-safety issues when profiling or tracing all
threads via PyEval_SetProfileAllThreads or PyEval_SetTraceAllThreads:

* The loop over thread states could crash if a thread exits concurrently
  (in both the free threading and default build)
* The modification of `c_profilefunc` and `c_tracefunc` wasn't
  thread-safe on the free threading build.
(cherry picked from commit a10152f8fd)
2025-10-09 11:42:47 -04:00
Łukasz Langa
f6186a3709
[3.13] gh-133400: Fixed Ctrl+D (^D) behavior in :mod:_pyrepl module (GH-133883) (GH-139851)
(cherry picked from commit 81959a0364)

Co-authored-by: DeepWzh <wzh2012@outlook.com>
Co-authored-by: adam j hartz <adam@smatz.net>
2025-10-09 17:38:10 +02:00
Miss Islington (bot)
abe6f529ff
[3.13] gh-75989: TarFile.extractall and TarFile.extract now overwrite symlinks when extracting hardlinks (GH-137316) (GH-139771)
(cherry picked from commit 481d5b5455)

Co-authored-by: Alexander Urieles <aeurielesn@users.noreply.github.com>
2025-10-09 12:54:14 +02:00