mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
gh-98831: Modernize FORMAT_VALUE (#101628)
Generator update: support balanced parentheses and brackets in conditions and size expressions.
This commit is contained in:
parent
aacbdb0c65
commit
b2b85b5db9
5 changed files with 24 additions and 35 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue