mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-132661: Implement PEP 750 (#132662)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Wingy <git@wingysam.xyz> Co-authored-by: Koudai Aono <koxudaxi@gmail.com> Co-authored-by: Dave Peck <davepeck@gmail.com> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Paul Everitt <pauleveritt@me.com> Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
parent
5ea9010e89
commit
60202609a2
81 changed files with 7716 additions and 3761 deletions
83
Python/executor_cases.c.h
generated
83
Python/executor_cases.c.h
generated
|
@ -2604,6 +2604,89 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _BUILD_INTERPOLATION: {
|
||||
_PyStackRef *format;
|
||||
_PyStackRef str;
|
||||
_PyStackRef value;
|
||||
_PyStackRef interpolation;
|
||||
oparg = CURRENT_OPARG();
|
||||
format = &stack_pointer[-(oparg & 1)];
|
||||
str = stack_pointer[-1 - (oparg & 1)];
|
||||
value = stack_pointer[-2 - (oparg & 1)];
|
||||
PyObject *value_o = PyStackRef_AsPyObjectBorrow(value);
|
||||
PyObject *str_o = PyStackRef_AsPyObjectBorrow(str);
|
||||
int conversion = oparg >> 2;
|
||||
PyObject *format_o;
|
||||
if (oparg & 1) {
|
||||
format_o = PyStackRef_AsPyObjectBorrow(format[0]);
|
||||
}
|
||||
else {
|
||||
format_o = &_Py_STR(empty);
|
||||
}
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyObject *interpolation_o = _PyInterpolation_Build(value_o, str_o, conversion, format_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (oparg & 1) {
|
||||
stack_pointer += -(oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(format[0]);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
}
|
||||
else {
|
||||
stack_pointer += -(oparg & 1);
|
||||
}
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(str);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(value);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (interpolation_o == NULL) {
|
||||
JUMP_TO_ERROR();
|
||||
}
|
||||
interpolation = PyStackRef_FromPyObjectSteal(interpolation_o);
|
||||
stack_pointer[0] = interpolation;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BUILD_TEMPLATE: {
|
||||
_PyStackRef interpolations;
|
||||
_PyStackRef strings;
|
||||
_PyStackRef template;
|
||||
interpolations = stack_pointer[-1];
|
||||
strings = stack_pointer[-2];
|
||||
PyObject *strings_o = PyStackRef_AsPyObjectBorrow(strings);
|
||||
PyObject *interpolations_o = PyStackRef_AsPyObjectBorrow(interpolations);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyObject *template_o = _PyTemplate_Build(strings_o, interpolations_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(interpolations);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(strings);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (template_o == NULL) {
|
||||
JUMP_TO_ERROR();
|
||||
}
|
||||
template = PyStackRef_FromPyObjectSteal(template_o);
|
||||
stack_pointer[0] = template;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BUILD_TUPLE: {
|
||||
_PyStackRef *values;
|
||||
_PyStackRef tup;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue