From 26bbd7248ca49eb4c50888524555854cbf7f7e06 Mon Sep 17 00:00:00 2001 From: dr-carlos Date: Thu, 13 Aug 2026 18:15:54 +0930 Subject: [PATCH] Test `type_repr()` of `Template` with invalid syntax in `Interpolation` --- Lib/test/test_annotationlib.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/test/test_annotationlib.py b/Lib/test/test_annotationlib.py index 5087c3ca425f1fc..aa155370cffb7e5 100644 --- a/Lib/test/test_annotationlib.py +++ b/Lib/test/test_annotationlib.py @@ -1874,6 +1874,10 @@ def nested(): type_repr(Template("hi", Interpolation(42, " "))), "Template('hi', Interpolation(42, ' ', None, ''))", ) + self.assertEqual( + type_repr(Template("hi", Interpolation(42, "4!2"))), + "Template('hi', Interpolation(42, '4!2', None, ''))", + ) # gh138558: perhaps in the future, we can improve this behavior: self.assertEqual(type_repr(Template(Interpolation(42, "99"))), "t'{99}'")