Skip to content

Commit

Permalink
bpo-395222: Correctly unparse unicode prefix in ast_unparse.c (python…
Browse files Browse the repository at this point in the history
  • Loading branch information
isidentical authored Apr 14, 2020
1 parent 96515e9 commit aade1cc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lib/test/test_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def test_annotations(self):
eq = self.assertAnnotationEqual
eq('...')
eq("'some_string'")
eq("u'some_string'")
eq("b'\\xa3'")
eq('Name')
eq('None')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Correctly unparse explicit ``u`` prefix for strings when postponed
evaluation for annotations activated. Patch by Batuhan Taskaya.
2 changes: 2 additions & 0 deletions Python/ast_unparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, int level)
if (e->v.Constant.value == Py_Ellipsis) {
APPEND_STR_FINISH("...");
}
APPEND_STR_IF(e->v.Constant.kind != NULL,
PyUnicode_AS_DATA(e->v.Constant.kind));
return append_ast_constant(writer, e->v.Constant.value);
case JoinedStr_kind:
return append_joinedstr(writer, e, false);
Expand Down

0 comments on commit aade1cc

Please sign in to comment.