Skip to content

Commit 1255bea

Browse files
Merge branch 'main' into yyang/call_len_opt
2 parents 4f523dc + 6f57914 commit 1255bea

25 files changed

+415
-246
lines changed

Doc/faq/programming.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,13 +1226,13 @@ This converts the list into a set, thereby removing duplicates, and then back
12261226
into a list.
12271227

12281228

1229-
How do you remove multiple items from a list
1230-
--------------------------------------------
1229+
How do you remove multiple items from a list?
1230+
---------------------------------------------
12311231

12321232
As with removing duplicates, explicitly iterating in reverse with a
12331233
delete condition is one possibility. However, it is easier and faster
12341234
to use slice replacement with an implicit or explicit forward iteration.
1235-
Here are three variations.::
1235+
Here are three variations::
12361236

12371237
mylist[:] = filter(keep_function, mylist)
12381238
mylist[:] = (x for x in mylist if keep_condition)

Doc/library/base64.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ Refer to the documentation of the individual functions for more information.
254254
*adobe* controls whether the input sequence is in Adobe Ascii85 format
255255
(i.e. is framed with <~ and ~>).
256256

257-
*ignorechars* should be a :term:`bytes-like object` or ASCII string
258-
containing characters to ignore
257+
*ignorechars* should be a byte string containing characters to ignore
259258
from the input. This should only contain whitespace characters, and by
260259
default contains all whitespace characters in ASCII.
261260

Doc/library/inspect.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
524524

525525
.. versionchanged:: 3.13
526526
Functions wrapped in :func:`functools.partialmethod` now return ``True``
527-
if the wrapped function is a :term:`coroutine function`.
527+
if the wrapped function is a :term:`asynchronous generator` function.
528528

529529
.. function:: isasyncgen(object)
530530

Include/internal/pycore_opcode_metadata.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_ids.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/email/generator.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
NLCRE = re.compile(r'\r\n|\r|\n')
2323
fcre = re.compile(r'^From ', re.MULTILINE)
2424
NEWLINE_WITHOUT_FWSP = re.compile(r'\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]')
25+
NEWLINE_WITHOUT_FWSP_BYTES = re.compile(br'\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]')
2526

2627

2728
class Generator:
@@ -429,7 +430,16 @@ def _write_headers(self, msg):
429430
# This is almost the same as the string version, except for handling
430431
# strings with 8bit bytes.
431432
for h, v in msg.raw_items():
432-
self._fp.write(self.policy.fold_binary(h, v))
433+
folded = self.policy.fold_binary(h, v)
434+
if self.policy.verify_generated_headers:
435+
linesep = self.policy.linesep.encode()
436+
if not folded.endswith(linesep):
437+
raise HeaderWriteError(
438+
f'folded header does not end with {linesep!r}: {folded!r}')
439+
if NEWLINE_WITHOUT_FWSP_BYTES.search(folded.removesuffix(linesep)):
440+
raise HeaderWriteError(
441+
f'folded header contains newline: {folded!r}')
442+
self._fp.write(folded)
433443
# A blank line always separates headers from body
434444
self.write(self._NL)
435445

Lib/idlelib/News3.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
What's New in IDLE 3.15.0
2+
(since 3.14.0)
3+
Released on 2026-10-01
4+
=========================
5+
6+
7+
gh-143774: Better explain the operation of Format / Format Paragraph.
8+
Patch by Terry J. Reedy.
9+
10+
gh-139742: Colorize t-string prefixes for template strings in IDLE,
11+
as done for f-string prefixes. Patch by Anuradha Agrawal.
12+
113
What's New in IDLE 3.14.0
214
(since 3.13.0)
315
Released on 2025-10-07
416
=========================
517

6-
718
gh-129873: Simplify displaying the IDLE doc by only copying the text
819
section of idle.html to idlelib/help.html. Patch by Stan Ulbrych.
920

Lib/test/test_base64.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,19 @@ def test_a85decode_errors(self):
965965
self.assertRaises(ValueError, base64.a85decode, b'aaaay',
966966
foldspaces=True)
967967

968+
self.assertEqual(base64.a85decode(b"a b\nc", ignorechars=b" \n"),
969+
b'\xc9\x89')
970+
with self.assertRaises(ValueError):
971+
base64.a85decode(b"a b\nc", ignorechars=b"")
972+
with self.assertRaises(ValueError):
973+
base64.a85decode(b"a b\nc", ignorechars=b" ")
974+
with self.assertRaises(ValueError):
975+
base64.a85decode(b"a b\nc", ignorechars=b"\n")
976+
with self.assertRaises(TypeError):
977+
base64.a85decode(b"a b\nc", ignorechars=" \n")
978+
with self.assertRaises(TypeError):
979+
base64.a85decode(b"a b\nc", ignorechars=None)
980+
968981
def test_b85decode_errors(self):
969982
illegal = list(range(33)) + \
970983
list(b'"\',./:[\\]') + \

Lib/test/test_capi/test_opt.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,6 +2912,46 @@ def testfunc(n):
29122912
self.assertIn("_POP_TOP_NOP", uops)
29132913
self.assertLessEqual(count_ops(ex, "_POP_TOP"), 2)
29142914

2915+
def test_binary_op_refcount_elimination(self):
2916+
class CustomAdder:
2917+
def __init__(self, val):
2918+
self.val = val
2919+
def __add__(self, other):
2920+
return CustomAdder(self.val + other.val)
2921+
2922+
def testfunc(n):
2923+
a = CustomAdder(1)
2924+
b = CustomAdder(2)
2925+
res = None
2926+
for _ in range(n):
2927+
res = a + b
2928+
return res.val if res else 0
2929+
2930+
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
2931+
self.assertEqual(res, 3)
2932+
self.assertIsNotNone(ex)
2933+
uops = get_opnames(ex)
2934+
self.assertIn("_BINARY_OP", uops)
2935+
self.assertIn("_POP_TOP_NOP", uops)
2936+
self.assertLessEqual(count_ops(ex, "_POP_TOP"), 2)
2937+
2938+
def test_binary_op_extend_float_long_add_refcount_elimination(self):
2939+
def testfunc(n):
2940+
a = 1.5
2941+
b = 2
2942+
res = 0.0
2943+
for _ in range(n):
2944+
res = a + b
2945+
return res
2946+
2947+
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
2948+
self.assertEqual(res, 3.5)
2949+
self.assertIsNotNone(ex)
2950+
uops = get_opnames(ex)
2951+
self.assertIn("_BINARY_OP_EXTEND", uops)
2952+
self.assertIn("_POP_TOP_NOP", uops)
2953+
self.assertLessEqual(count_ops(ex, "_POP_TOP"), 2)
2954+
29152955
def test_remove_guard_for_slice_list(self):
29162956
def f(n):
29172957
for i in range(n):

0 commit comments

Comments
 (0)