From 93918795b8f9fae81c7f3c91da586e5a859a4496 Mon Sep 17 00:00:00 2001 From: youknowdot Date: Sat, 10 Oct 2026 09:39:56 +0900 Subject: [PATCH] Align required canonical test expectations with Python 3.15 Take only demonstrated contract changes from CPython v3.15.0, d220409a13b77de7a6c30abe16ea90db01528edc: removed module __cached__, Struct format exception classes, and decimal-format diagnostic. Preserve unrelated tests and expectations. Assisted-by: OpenAI Codex:model identifier unavailable --- Lib/test/test_cmd_line_script.py | 3 --- Lib/test/test_peepholer.py | 3 ++- Lib/test/test_struct.py | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index 8dd64afcc..a2ea05353 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -44,7 +44,6 @@ from importlib.machinery import BuiltinImporter _loader = __loader__ if __loader__ is BuiltinImporter else type(__loader__) print('__loader__==%a' % _loader) print('__file__==%a' % __file__) -print('__cached__==%a' % __cached__) print('__package__==%r' % __package__) # Check PEP 451 details import os.path @@ -58,8 +57,6 @@ if __package__ is not None: assertEqual(__spec__.parent, __package__) assertIdentical(__spec__.submodule_search_locations, None) assertEqual(__spec__.origin, __file__) - if __spec__.cached is not None: - assertEqual(__spec__.cached, __cached__) # Check the sys module import sys assertIdentical(globals(), sys.modules[__name__].__dict__) diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index d06b9a4b6..66af5ae7c 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -743,7 +743,8 @@ class TestTranforms(BytecodeTestCase): eval("'%s%z' % (x,)", {'x': 1234}) with self.assertRaisesRegex(ValueError, 'unsupported format character'): eval("'%s%z' % (x, 5)", {'x': 1234}) - with self.assertRaisesRegex(TypeError, 'a real number is required, not str'): + with self.assertRaisesRegex(TypeError, + 'format argument 1: %d requires a real number, not str'): eval("'%d' % (x,)", {'x': '1234'}) with self.assertRaisesRegex(TypeError, 'an integer is required, not float'): eval("'%x' % (x,)", {'x': 1234.56}) diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index e18bad9c9..13e323de9 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -622,7 +622,7 @@ class StructTest(ComplexesAreIdenticalMixin, unittest.TestCase): self.assertEqual(s.pack(1, 2), packed) self.assertEqual(s.unpack(packed), (1, 2)) - with self.assertRaises(UnicodeEncodeError): + with self.assertRaises(ValueError): s.__init__('\udc00') self.assertEqual(s.format, '>hh') self.assertEqual(s.pack(1, 2), packed) @@ -882,7 +882,7 @@ class StructTest(ComplexesAreIdenticalMixin, unittest.TestCase): self.assertRaises(RuntimeError, S.pack_into, spam, 1) self.assertRaises(RuntimeError, S.unpack, spam) self.assertRaises(RuntimeError, S.unpack_from, spam) - self.assertRaises(RuntimeError, getattr, S, 'format') + self.assertRaises(AttributeError, getattr, S, 'format') self.assertRaises(RuntimeError, S.__sizeof__) self.assertRaises(RuntimeError, repr, S) self.assertEqual(S.size, -1)