From 4f3cab96c166031a184a1abf288a4d65df49fe52 Mon Sep 17 00:00:00 2001 From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com> Date: Fri, 12 Sep 2025 09:47:43 +0200 Subject: [PATCH 1/4] gh-138801: re-enable `pyrepl` tests on Windows (#138802) --- Lib/test/test_pyrepl/__init__.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_pyrepl/__init__.py b/Lib/test/test_pyrepl/__init__.py index 8ef472eb0cffaf..2f37bff6df8b4a 100644 --- a/Lib/test/test_pyrepl/__init__.py +++ b/Lib/test/test_pyrepl/__init__.py @@ -1,14 +1,10 @@ import os -from test.support import load_package_tests -import unittest +import sys +from test.support import import_helper, load_package_tests -try: - import termios -except ImportError: - raise unittest.SkipTest("termios required") -else: - del termios +if sys.platform != "win32": + import_helper.import_module("termios") def load_tests(*args): From 44991619ba04a98c5878ee5bbc38d2e47cbd22c7 Mon Sep 17 00:00:00 2001 From: Jan-Eric Nitschke <47750513+JanEricNitschke@users.noreply.github.com> Date: Fri, 12 Sep 2025 11:33:38 +0200 Subject: [PATCH 2/4] gh-138669: Increase test coverage for difflib (GH-138670) --- Lib/test/test_difflib.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py index 0eab3f523dc5fe..771fd46e042a41 100644 --- a/Lib/test/test_difflib.py +++ b/Lib/test/test_difflib.py @@ -29,6 +29,16 @@ def test_one_delete(self): ('delete', 40, 41, 40, 40), ('equal', 41, 81, 40, 80)]) + def test_opcode_caching(self): + sm = difflib.SequenceMatcher(None, 'b' * 100, 'a' + 'b' * 100) + opcode = sm.get_opcodes() + self.assertEqual(opcode, + [ ('insert', 0, 0, 0, 1), + ('equal', 0, 100, 1, 101)]) + # Implementation detail: opcodes are cached; + # `get_opcodes()` returns the same object + self.assertIs(opcode, sm.get_opcodes()) + def test_bjunk(self): sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ', a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40) @@ -293,6 +303,15 @@ def test_close_matches_aligned(self): '+ kitten\n', '+ puppy\n']) + def test_one_insert(self): + m = difflib.Differ().compare('b' * 2, 'a' + 'b' * 2) + self.assertEqual(list(m), ['+ a', ' b', ' b']) + + def test_one_delete(self): + m = difflib.Differ().compare('a' + 'b' * 2, 'b' * 2) + self.assertEqual(list(m), ['- a', ' b', ' b']) + + class TestOutputFormat(unittest.TestCase): def test_tab_delimiter(self): args = [['one'], ['two'], 'Original', 'Current', @@ -601,6 +620,26 @@ def test_longest_match_with_popular_chars(self): self.assertFalse(self.longer_match_exists(a, b, match.size)) +class TestCloseMatches(unittest.TestCase): + # Happy paths are tested in the doctests of `difflib.get_close_matches`. + + def test_invalid_inputs(self): + self.assertRaises(ValueError, difflib.get_close_matches, "spam", ['egg'], n=0) + self.assertRaises(ValueError, difflib.get_close_matches, "spam", ['egg'], n=-1) + self.assertRaises(ValueError, difflib.get_close_matches, "spam", ['egg'], cutoff=1.1) + self.assertRaises(ValueError, difflib.get_close_matches, "spam", ['egg'], cutoff=-0.1) + + +class TestRestore(unittest.TestCase): + # Happy paths are tested in the doctests of `difflib.restore`. + + def test_invalid_input(self): + with self.assertRaises(ValueError): + ''.join(difflib.restore([], 0)) + with self.assertRaises(ValueError): + ''.join(difflib.restore([], 3)) + + def setUpModule(): difflib.HtmlDiff._default_prefix = 0 From 492941459acb5b5a104d96414288601d2e2b7e6f Mon Sep 17 00:00:00 2001 From: jxes993409 <68891412+jxes993409@users.noreply.github.com> Date: Fri, 12 Sep 2025 17:37:53 +0800 Subject: [PATCH 3/4] gh-138163: skip failures if tests are run with `SCHED_BATCH` on glibc (GH-138576) --- Lib/test/test_posix.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 2af11888b17c1d..0bb65fe717d359 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -2036,6 +2036,12 @@ def test_setscheduler_only_param(self): @requires_sched @unittest.skipIf(sys.platform.startswith(('freebsd', 'netbsd')), "bpo-34685: test can fail on BSD") + @unittest.skipIf(platform.libc_ver()[0] == 'glibc' and + os.sched_getscheduler(0) in [ + os.SCHED_BATCH, + os.SCHED_IDLE, + os.SCHED_DEADLINE], + "Skip test due to glibc posix_spawn policy") def test_setscheduler_with_policy(self): policy = os.sched_getscheduler(0) priority = os.sched_get_priority_min(policy) From 3d521a62e7c377ac518c9f0326a88be204f0e3aa Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 12 Sep 2025 11:46:02 +0200 Subject: [PATCH 4/4] gh-138756: Fix leak of inittab memory in PyInitConfig_Free() (GH-138792) --- Python/initconfig.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/initconfig.c b/Python/initconfig.c index 951730c9ea3eb5..efb276ac680ed9 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -3729,6 +3729,7 @@ PyInitConfig_Free(PyInitConfig *config) } initconfig_free_config(&config->config); + PyMem_RawFree(config->inittab); free(config->err_msg); free(config); }