Skip to content

Commit 235a6f0

Browse files
committed
Issue python#24965: Implement PEP 498 "Literal String Interpolation". Documentation is still needed, I'll open an issue for that.
1 parent aed8830 commit 235a6f0

9 files changed

Lines changed: 1965 additions & 63 deletions

File tree

Include/Python-ast.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
201201
SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11,
202202
Await_kind=12, Yield_kind=13, YieldFrom_kind=14,
203203
Compare_kind=15, Call_kind=16, Num_kind=17, Str_kind=18,
204-
Bytes_kind=19, NameConstant_kind=20, Ellipsis_kind=21,
205-
Attribute_kind=22, Subscript_kind=23, Starred_kind=24,
206-
Name_kind=25, List_kind=26, Tuple_kind=27};
204+
FormattedValue_kind=19, JoinedStr_kind=20, Bytes_kind=21,
205+
NameConstant_kind=22, Ellipsis_kind=23, Attribute_kind=24,
206+
Subscript_kind=25, Starred_kind=26, Name_kind=27,
207+
List_kind=28, Tuple_kind=29};
207208
struct _expr {
208209
enum _expr_kind kind;
209210
union {
@@ -296,6 +297,16 @@ struct _expr {
296297
string s;
297298
} Str;
298299

300+
struct {
301+
expr_ty value;
302+
int conversion;
303+
expr_ty format_spec;
304+
} FormattedValue;
305+
306+
struct {
307+
asdl_seq *values;
308+
} JoinedStr;
309+
299310
struct {
300311
bytes s;
301312
} Bytes;
@@ -543,6 +554,12 @@ expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, int
543554
expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena);
544555
#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3)
545556
expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena);
557+
#define FormattedValue(a0, a1, a2, a3, a4, a5) _Py_FormattedValue(a0, a1, a2, a3, a4, a5)
558+
expr_ty _Py_FormattedValue(expr_ty value, int conversion, expr_ty format_spec,
559+
int lineno, int col_offset, PyArena *arena);
560+
#define JoinedStr(a0, a1, a2, a3) _Py_JoinedStr(a0, a1, a2, a3)
561+
expr_ty _Py_JoinedStr(asdl_seq * values, int lineno, int col_offset, PyArena
562+
*arena);
546563
#define Bytes(a0, a1, a2, a3) _Py_Bytes(a0, a1, a2, a3)
547564
expr_ty _Py_Bytes(bytes s, int lineno, int col_offset, PyArena *arena);
548565
#define NameConstant(a0, a1, a2, a3) _Py_NameConstant(a0, a1, a2, a3)

0 commit comments

Comments
 (0)