From 55718cb6eda1a28b4c02b3be97b46944e427418a Mon Sep 17 00:00:00 2001 From: Eduardo Villalpando Mello Date: Sat, 23 May 2026 23:45:56 -0700 Subject: [PATCH 1/3] gh-150244: Fix `test_create_subprocess_env_shell` to handle PATH with spaces (#150281) --- Lib/test/test_asyncio/test_subprocess.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py index c08eb7cf2615680..4ac6b23b7120fcc 100644 --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -1,4 +1,5 @@ import os +import shlex import signal import sys import textwrap @@ -770,9 +771,7 @@ async def check_stdout_output(self, coro, output): def test_create_subprocess_env_shell(self) -> None: async def main() -> None: - executable = sys.executable - if sys.platform == "win32": - executable = f'"{executable}"' + executable = f'"{sys.executable}"' if sys.platform == "win32" else shlex.quote(sys.executable) cmd = f'''{executable} -c "import os, sys; sys.stdout.write(os.getenv('FOO'))"''' env = os.environ.copy() env["FOO"] = "bar" From a38804bb981ba93a1efbb95a1e35a1c0b05740c7 Mon Sep 17 00:00:00 2001 From: siliconforks Date: Sun, 24 May 2026 04:22:13 -0300 Subject: [PATCH 2/3] gh-148444: Use "zero of any numeric type" instead of "numeric zero of all types" (#148455) --- Doc/reference/expressions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 68dcfc00bbd99c3..76e1ee74e35def9 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -2048,7 +2048,7 @@ Boolean operations In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: -``False``, ``None``, numeric zero of all types, and empty strings and containers +``False``, ``None``, zero of any numeric type, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets). All other values are interpreted as true. User-defined objects can customize their truth value by providing a :meth:`~object.__bool__` method. From 0851700a9d99ca4bebd8d5f9d73c8c9ab1084405 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sun, 24 May 2026 13:24:59 +0300 Subject: [PATCH 3/3] gh-119949: Refactor test_exc() helper in test_format.py (GH-135452) Use assertRaisesRegex() context and fix https://github.com/python/cpython/pull/119781#pullrequestreview-2088240959 * address review: minimize diff --- Lib/test/test_format.py | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index 00f1ab44b0a8fa8..5d322cb444cfb68 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -68,33 +68,20 @@ def testcommon(formatstr, args, output=None, limit=None, overflowok=False): testformat(b_format, args, b_output, limit, overflowok) testformat(ba_format, args, ba_output, limit, overflowok) -def test_exc(formatstr, args, exception, excmsg): - try: - testformat(formatstr, args) - except exception as exc: - if str(exc) == excmsg: - if verbose: - print("yes") - else: - if verbose: print('no') - print('Unexpected ', exception, ':', repr(str(exc))) - raise - except: - if verbose: print('no') - print('Unexpected exception') - raise - else: - raise TestFailed('did not get expected exception: %s' % excmsg) - -def test_exc_common(formatstr, args, exception, excmsg): - # test str and bytes - test_exc(formatstr, args, exception, excmsg) - if isinstance(args, dict): - args = {k.encode('ascii'): v for k, v in args.items()} - test_exc(formatstr.encode('ascii'), args, exception, excmsg) class FormatTest(unittest.TestCase): + def check_exc(self, formatstr, args, exception, excmsg): + with self.assertRaisesRegex(exception, re.escape(excmsg)): + testformat(formatstr, args) + + def check_exc_common(self, formatstr, args, exception, excmsg): + # test str and bytes + self.check_exc(formatstr, args, exception, excmsg) + if isinstance(args, dict): + args = {k.encode('ascii'): v for k, v in args.items()} + self.check_exc(formatstr.encode('ascii'), args, exception, excmsg) + def test_common_format(self): # test the format identifiers that work the same across # str, bytes, and bytearrays (integer, float, oct, hex) @@ -271,6 +258,7 @@ def test_common_format(self): if verbose: print('Testing exceptions') + test_exc_common = self.check_exc_common test_exc_common('abc %', (), ValueError, "stray % at position 4") test_exc_common('abc % %s', 1, ValueError, "stray % at position 4 or unexpected format character '%' at position 6") @@ -365,6 +353,7 @@ def test_str_format(self): # Test exception for unknown format characters, etc. if verbose: print('Testing exceptions') + test_exc = self.check_exc test_exc('abc %b', 1, ValueError, "unsupported format %b at position 4") test_exc("abc %\nd", 1, ValueError, @@ -468,6 +457,7 @@ def __bytes__(self): # Test exception for unknown format characters, etc. if verbose: print('Testing exceptions') + test_exc = self.check_exc test_exc(b"abc %\nd", 1, ValueError, "stray % at position 4 or unexpected format character with code 0x0a at position 5") test_exc(b"abc %'d", 1, ValueError,