Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

DO NOT MERGE -- Tag strings #103766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Prev Previous commit
Next Next commit
Correctly unparse TagString node
  • Loading branch information
gvanrossum committed May 3, 2022
commit a9922f4824c267ac88f11725b48a0ae4681901ae
14 changes: 13 additions & 1 deletion 14 Python/ast_unparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,18 @@ append_joinedstr(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec)
return result;
}

static int
append_tagstring(_PyUnicodeWriter *writer, expr_ty e, int level)
{
if (-1 == append_ast_expr(writer, e->v.TagString.tag, level))
return -1;
if (-1 == append_charp(writer, " "))
return -1;
if (-1 == append_ast_expr(writer, e->v.TagString.str, level))
return -1;
return 0;
}

static int
append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e)
{
Expand Down Expand Up @@ -888,7 +900,7 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, int level)
case JoinedStr_kind:
return append_joinedstr(writer, e, false);
case TagString_kind:
assert(0); // TODO
return append_tagstring(writer, e, level);
case FormattedValue_kind:
return append_formattedvalue(writer, e);
/* The following exprs can be assignment targets. */
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.