From 8822166200ddb4a7635337b97b626e658a443cef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bartosz=20S=C5=82awecki?=
Date: Thu, 6 Nov 2025 06:39:07 +0100
Subject: [PATCH 1/8] gh-140569: recommend the new REPL in the asyncio REPL
docs (#140570)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
---
Doc/library/asyncio.rst | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Doc/library/asyncio.rst b/Doc/library/asyncio.rst
index 444db01390d922..0f72e31dee5f1d 100644
--- a/Doc/library/asyncio.rst
+++ b/Doc/library/asyncio.rst
@@ -79,6 +79,10 @@ You can experiment with an ``asyncio`` concurrent context in the :term:`REPL`:
>>> await asyncio.sleep(10, result='hello')
'hello'
+This REPL provides limited compatibility with :envvar:`PYTHON_BASIC_REPL`.
+It is recommended that the default REPL is used
+for full functionality and the latest features.
+
.. audit-event:: cpython.run_stdin "" ""
.. versionchanged:: 3.12.5 (also 3.11.10, 3.10.15, 3.9.20, and 3.8.20)
From 9037a386c6ed0c71cf8525ef91c55694ebeedc36 Mon Sep 17 00:00:00 2001
From: RayXu <140802139+F18-Maverick@users.noreply.github.com>
Date: Thu, 6 Nov 2025 13:48:30 +0800
Subject: [PATCH 2/8] docs: fix a grammatical error in function.rst (#140990)
---
Doc/c-api/function.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Doc/c-api/function.rst b/Doc/c-api/function.rst
index 764b2ac610be4d..0bac638957155e 100644
--- a/Doc/c-api/function.rst
+++ b/Doc/c-api/function.rst
@@ -200,7 +200,7 @@ There are a few functions specific to Python functions.
runtime behavior depending on optimization decisions, it does not change
the semantics of the Python code being executed.
- If *event* is ``PyFunction_EVENT_DESTROY``, Taking a reference in the
+ If *event* is ``PyFunction_EVENT_DESTROY``, taking a reference in the
callback to the about-to-be-destroyed function will resurrect it, preventing
it from being freed at this time. When the resurrected object is destroyed
later, any watcher callbacks active at that time will be called again.
From d6c89a2df2c8b7603125883494e9058a88348f66 Mon Sep 17 00:00:00 2001
From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Date: Thu, 6 Nov 2025 05:50:57 +0000
Subject: [PATCH 3/8] gh-140939: Fix memory leak in `_PyBytes_FormatEx` error
path (#140957)
---
Lib/test/test_bytes.py | 7 +++++++
.../2025-11-03-17-21-38.gh-issue-140939.FVboAw.rst | 2 ++
Objects/bytesobject.c | 1 +
3 files changed, 10 insertions(+)
create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-11-03-17-21-38.gh-issue-140939.FVboAw.rst
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index f10e4041937f4f..e012042159d223 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -802,6 +802,13 @@ def __int__(self):
with self.assertRaisesRegex(TypeError, msg):
operator.mod(format_bytes, value)
+ def test_memory_leak_gh_140939(self):
+ # gh-140939: MemoryError is raised without leaking
+ _testcapi = import_helper.import_module('_testcapi')
+ with self.assertRaises(MemoryError):
+ b = self.type2test(b'%*b')
+ b % (_testcapi.PY_SSIZE_T_MAX, b'abc')
+
def test_imod(self):
b = self.type2test(b'hello, %b!')
orig = b
diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-03-17-21-38.gh-issue-140939.FVboAw.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-03-17-21-38.gh-issue-140939.FVboAw.rst
new file mode 100644
index 00000000000000..a2921761f75556
--- /dev/null
+++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-03-17-21-38.gh-issue-140939.FVboAw.rst
@@ -0,0 +1,2 @@
+Fix memory leak when :class:`bytearray` or :class:`bytes` is formated with the
+``%*b`` format with a large width that results in a :exc:`MemoryError`.
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 9c807b3dd166ee..2b9513abe91956 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -985,6 +985,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
if (alloc > 2) {
res = PyBytesWriter_GrowAndUpdatePointer(writer, alloc - 2, res);
if (res == NULL) {
+ Py_XDECREF(temp);
goto error;
}
}
From 6a7c969d003d3ba932d5c7f14a58e2a6408f4a3d Mon Sep 17 00:00:00 2001
From: Terry Jan Reedy
Date: Thu, 6 Nov 2025 03:08:24 -0500
Subject: [PATCH 4/8] gh-129876: Move misplaced IDLE news item (#141118)
---
Lib/idlelib/News3.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Lib/idlelib/News3.txt b/Lib/idlelib/News3.txt
index 30784578cc637f..53d83762f99ec5 100644
--- a/Lib/idlelib/News3.txt
+++ b/Lib/idlelib/News3.txt
@@ -4,6 +4,9 @@ Released on 2025-10-07
=========================
+gh-129873: Simplify displaying the IDLE doc by only copying the text
+section of idle.html to idlelib/help.html. Patch by Stan Ulbrych.
+
gh-112936: IDLE - Include Shell menu in single-process mode,
though with Restart Shell and View Last Restart disabled.
Patch by Zhikang Yan.
@@ -26,9 +29,6 @@ Released on 2024-10-07
gh-120104: Fix padding in config and search dialog windows in IDLE.
-gh-129873: Simplify displaying the IDLE doc by only copying the text
-section of idle.html to idlelib/help.html. Patch by Stan Ulbrych.
-
gh-120083: Add explicit black IDLE Hovertip foreground color needed for
recent macOS. Fixes Sonoma showing unreadable white on pale yellow.
Patch by John Riggles.
From 4e6e208be9d1c52d1b55a8bb3a83682cb078e55e Mon Sep 17 00:00:00 2001
From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Date: Thu, 6 Nov 2025 08:21:02 +0000
Subject: [PATCH 5/8] Minor fixes to `idle.rst` and regenerate `help.html`
(#140037)
---
.gitattributes | 1 +
Doc/library/idle.rst | 6 +--
Lib/idlelib/help.html | 110 ++++++++++++++++++++++++++++++------------
3 files changed, 82 insertions(+), 35 deletions(-)
diff --git a/.gitattributes b/.gitattributes
index 823e3e975a23a8..d654721239318e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -83,6 +83,7 @@ Include/opcode_ids.h generated
Include/token.h generated
Lib/_opcode_metadata.py generated
Lib/keyword.py generated
+Lib/idlelib/help.html generated
Lib/test/certdata/*.pem generated
Lib/test/certdata/*.0 generated
Lib/test/levenshtein_examples.json generated
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index e547c96b580bfd..10ec7f0a6f14c9 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -13,7 +13,7 @@ IDLE --- Python editor and shell
single: Integrated Development Environment
..
- Remember to update Lib/idlelib/help.html with idlelib.help.copy_source() when modifying this file.
+ Remember to update Lib/idlelib/help.html with idlelib.help.copy_strip() when modifying this file.
--------------
@@ -88,7 +88,7 @@ Save
Save As...
Save the current window with a Save As dialog. The file saved becomes the
- new associated file for the window. (If your file namager is set to hide
+ new associated file for the window. (If your file manager is set to hide
extensions, the current extension will be omitted in the file name box.
If the new filename has no '.', '.py' and '.txt' will be added for Python
and text files, except that on macOS Aqua,'.py' is added for all files.)
@@ -206,7 +206,7 @@ New Indent Width
Strip Trailing Whitespace
Remove trailing space and other whitespace characters after the last
- non-whitespace character of a line by applying str.rstrip to each line,
+ non-whitespace character of a line by applying :meth:`str.rstrip` to each line,
including lines within multiline strings. Except for Shell windows,
remove extra newlines at the end of the file.
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index ebff9a309d9081..fc618ab727d1fb 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -53,7 +53,7 @@ File menu (Shell and Editor) to each line,
including lines within multiline strings. Except for Shell windows,
remove extra newlines at the end of the file.
@@ -337,16 +337,16 @@ Key bindings