From d0130624d9fc7e1a2b0670ac6edfb467bbb1bc10 Mon Sep 17 00:00:00 2001 From: dr-carlos <77367421+dr-carlos@users.noreply.github.com> Date: Thu, 13 Aug 2026 23:48:35 +0930 Subject: [PATCH] gh-141174: Test `type_repr()` of `Template` with invalid syntax in `Interpolation` (GH-155661) Test `type_repr()` of `Template` with invalid syntax in `Interpolation` (cherry picked from commit 5cc9e466b02858d667fddb885b521ab2029c6e36) Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com> --- 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}'")