cpython: 9095a5787a82 (original) (raw)
Mercurial > cpython
changeset 100165:9095a5787a82
Fix issue 26287: While handling FORMAT_VALUE opcode, the top of stack was being corrupted if an error occurred in PyObject_Format(). [#26287]
Eric V. Smith eric@trueblade.com | |
---|---|
date | Fri, 05 Feb 2016 18:23:08 -0500 |
parents | d3be5c4507b4 |
children | f6a89f6cadd0 |
files | Lib/test/test_fstring.py Python/ceval.c |
diffstat | 2 files changed, 13 insertions(+), 2 deletions(-)[+] [-] Lib/test/test_fstring.py 11 Python/ceval.c 4 |
line wrap: on
line diff
--- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -692,6 +692,17 @@ 4}''', '7') r"f'{a(4]}'", ])
- def test_errors(self):
# see issue 26287[](#l1.8)
self.assertAllRaise(TypeError, 'non-empty',[](#l1.9)
[r"f'{(lambda: 0):x}'",[](#l1.10)
r"f'{(0,):x}'",[](#l1.11)
])[](#l1.12)
self.assertAllRaise(ValueError, 'Unknown format code',[](#l1.13)
[r"f'{1000:j}'",[](#l1.14)
r"f'{1000:j}'",[](#l1.15)
])[](#l1.16)
+ def test_loop(self): for i in range(1000): self.assertEqual(f'i:{i}', 'i:' + str(i))
--- a/Python/ceval.c +++ b/Python/ceval.c @@ -3383,7 +3383,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int int have_fmt_spec = (oparg & FVS_MASK) == FVS_HAVE_SPEC; fmt_spec = have_fmt_spec ? POP() : NULL;
value = TOP();[](#l2.7)
value = POP();[](#l2.8)
/* See if any conversion is specified. */ switch (which_conversion) { @@ -3426,7 +3426,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int goto error; }
SET_TOP(result);[](#l2.16)
PUSH(result);[](#l2.17) DISPATCH();[](#l2.18) }[](#l2.19)