mirror of
https://github.com/python/cpython.git
synced 2025-08-26 03:34:43 +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
|
@ -16,6 +16,7 @@
|
|||
#include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
|
||||
#include "pycore_function.h"
|
||||
#include "pycore_instruments.h"
|
||||
#include "pycore_interpolation.h" // _PyInterpolation_Build()
|
||||
#include "pycore_intrinsics.h"
|
||||
#include "pycore_long.h" // _PyLong_GetZero()
|
||||
#include "pycore_moduleobject.h" // PyModuleObject
|
||||
|
@ -30,6 +31,7 @@
|
|||
#include "pycore_setobject.h" // _PySet_NextEntry()
|
||||
#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
|
||||
#include "pycore_stackref.h"
|
||||
#include "pycore_template.h" // _PyTemplate_Build()
|
||||
#include "pycore_tuple.h" // _PyTuple_ITEMS()
|
||||
#include "pycore_typeobject.h" // _PySuper_Lookup()
|
||||
|
||||
|
@ -1903,6 +1905,40 @@ dummy_func(
|
|||
str = PyStackRef_FromPyObjectSteal(str_o);
|
||||
}
|
||||
|
||||
inst(BUILD_INTERPOLATION, (value, str, format[oparg & 1] -- interpolation)) {
|
||||
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);
|
||||
}
|
||||
PyObject *interpolation_o = _PyInterpolation_Build(value_o, str_o, conversion, format_o);
|
||||
if (oparg & 1) {
|
||||
PyStackRef_CLOSE(format[0]);
|
||||
}
|
||||
else {
|
||||
DEAD(format);
|
||||
}
|
||||
PyStackRef_CLOSE(str);
|
||||
PyStackRef_CLOSE(value);
|
||||
ERROR_IF(interpolation_o == NULL);
|
||||
interpolation = PyStackRef_FromPyObjectSteal(interpolation_o);
|
||||
}
|
||||
|
||||
inst(BUILD_TEMPLATE, (strings, interpolations -- template)) {
|
||||
PyObject *strings_o = PyStackRef_AsPyObjectBorrow(strings);
|
||||
PyObject *interpolations_o = PyStackRef_AsPyObjectBorrow(interpolations);
|
||||
PyObject *template_o = _PyTemplate_Build(strings_o, interpolations_o);
|
||||
PyStackRef_CLOSE(interpolations);
|
||||
PyStackRef_CLOSE(strings);
|
||||
ERROR_IF(template_o == NULL);
|
||||
template = PyStackRef_FromPyObjectSteal(template_o);
|
||||
}
|
||||
|
||||
inst(BUILD_TUPLE, (values[oparg] -- tup)) {
|
||||
PyObject *tup_o = _PyTuple_FromStackRefStealOnSuccess(values, oparg);
|
||||
if (tup_o == NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue