Skip to content

Commit 4005ee3

Browse files
committed
Adapt compile.c changes
1 parent fb5864e commit 4005ee3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Python/compile.c

+26
Original file line numberDiff line numberDiff line change
@@ -4368,6 +4368,30 @@ compiler_joined_str(struct compiler *c, expr_ty e)
43684368
return SUCCESS;
43694369
}
43704370

4371+
/* Used to implement tag strings */
4372+
static int
4373+
compiler_tag_string(struct compiler *c, expr_ty e)
4374+
{
4375+
location loc = LOC(e);
4376+
if (e->kind == TagString_kind) {
4377+
expr_ty tag = e->v.TagString.tag;
4378+
expr_ty str = e->v.TagString.str;
4379+
if (tag->kind == Name_kind) {
4380+
if (str->kind == JoinedStr_kind) {
4381+
// Generate code for tag(str1, str2, ...)
4382+
asdl_keyword_seq *keywords =
4383+
_Py_asdl_keyword_seq_new(0, c->c_arena);
4384+
if (keywords == NULL)
4385+
return 0;
4386+
ADDOP(c, loc, PUSH_NULL);
4387+
VISIT(c, expr, tag);
4388+
return compiler_call_helper(c, loc, 0, str->v.JoinedStr.values, keywords);
4389+
}
4390+
}
4391+
}
4392+
return compiler_error(c, loc, "More complicated tag-string not yet supported");
4393+
}
4394+
43714395
/* Used to implement f-strings. Format a single value. */
43724396
static int
43734397
compiler_formatted_value(struct compiler *c, expr_ty e)
@@ -5289,6 +5313,8 @@ compiler_visit_expr1(struct compiler *c, expr_ty e)
52895313
break;
52905314
case JoinedStr_kind:
52915315
return compiler_joined_str(c, e);
5316+
case TagString_kind:
5317+
return compiler_tag_string(c, e);
52925318
case FormattedValue_kind:
52935319
return compiler_formatted_value(c, e);
52945320
/* The following exprs can be assignment targets. */

0 commit comments

Comments
 (0)