summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_fstring.py11
-rw-r--r--Python/ceval.c4
2 files changed, 13 insertions, 2 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index d6f781c..a82dedf 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -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))
diff --git a/Python/ceval.c b/Python/ceval.c
index 743a969..b815ccd 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3383,7 +3383,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
int have_fmt_spec = (oparg & FVS_MASK) == FVS_HAVE_SPEC;
fmt_spec = have_fmt_spec ? POP() : NULL;
- value = TOP();
+ value = POP();
/* See if any conversion is specified. */
switch (which_conversion) {
@@ -3426,7 +3426,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
goto error;
}
- SET_TOP(result);
+ PUSH(result);
DISPATCH();
}