Fix issue 26287: While handling FORMAT_VALUE opcode, the top of stack was being corrupted if an error occurred in PyObject_Format().

This commit is contained in:
Eric V. Smith 2016-02-05 18:23:08 -05:00
parent a3643c280f
commit 135d5f49f6
2 changed files with 13 additions and 2 deletions

View file

@ -692,6 +692,17 @@ f'{a * x()}'"""
r"f'{a(4]}'",
])
def test_errors(self):
# see issue 26287
self.assertAllRaise(TypeError, 'non-empty',
[r"f'{(lambda: 0):x}'",
r"f'{(0,):x}'",
])
self.assertAllRaise(ValueError, 'Unknown format code',
[r"f'{1000:j}'",
r"f'{1000:j}'",
])
def test_loop(self):
for i in range(1000):
self.assertEqual(f'i:{i}', 'i:' + str(i))