diff options
author | Guido van Rossum <guido@python.org> | 2023-02-07 17:35:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-07 17:35:55 -0800 |
commit | b2b85b5db9cfdb24f966b61757536a898abc3830 (patch) | |
tree | b5f09e352132a15f5e782e75ce6205b3da0552b1 /Python/bytecodes.c | |
parent | aacbdb0c650492756738b044e6ddf8b72f89a1a2 (diff) | |
download | cpython-b2b85b5db9cfdb24f966b61757536a898abc3830.tar.gz cpython-b2b85b5db9cfdb24f966b61757536a898abc3830.zip |
gh-98831: Modernize FORMAT_VALUE (#101628)
Generator update: support balanced parentheses and brackets in conditions and size expressions.
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r-- | Python/bytecodes.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index c6c00a7ab9b..d0f0513a36f 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -3054,18 +3054,10 @@ dummy_func( ERROR_IF(slice == NULL, error); } - // error: FORMAT_VALUE has irregular stack effect - inst(FORMAT_VALUE) { + inst(FORMAT_VALUE, (value, fmt_spec if ((oparg & FVS_MASK) == FVS_HAVE_SPEC) -- result)) { /* Handles f-string value formatting. */ - PyObject *result; - PyObject *fmt_spec; - PyObject *value; PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; - int have_fmt_spec = (oparg & FVS_MASK) == FVS_HAVE_SPEC; - - fmt_spec = have_fmt_spec ? POP() : NULL; - value = POP(); /* See if any conversion is specified. */ switch (which_conversion) { @@ -3088,7 +3080,7 @@ dummy_func( Py_DECREF(value); if (result == NULL) { Py_XDECREF(fmt_spec); - goto error; + ERROR_IF(true, error); } value = result; } @@ -3106,12 +3098,8 @@ dummy_func( result = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_XDECREF(fmt_spec); - if (result == NULL) { - goto error; - } + ERROR_IF(result == NULL, error); } - - PUSH(result); } inst(COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) { |