bpo-395222: Correctly unparse unicode prefix in ast_unparse.c (GH-19512)
This commit is contained in:
parent
96515e9f67
commit
aade1cc453
|
@ -153,6 +153,7 @@ class AnnotationsFutureTestCase(unittest.TestCase):
|
||||||
eq = self.assertAnnotationEqual
|
eq = self.assertAnnotationEqual
|
||||||
eq('...')
|
eq('...')
|
||||||
eq("'some_string'")
|
eq("'some_string'")
|
||||||
|
eq("u'some_string'")
|
||||||
eq("b'\\xa3'")
|
eq("b'\\xa3'")
|
||||||
eq('Name')
|
eq('Name')
|
||||||
eq('None')
|
eq('None')
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Correctly unparse explicit ``u`` prefix for strings when postponed
|
||||||
|
evaluation for annotations activated. Patch by Batuhan Taskaya.
|
|
@ -875,6 +875,8 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, int level)
|
||||||
if (e->v.Constant.value == Py_Ellipsis) {
|
if (e->v.Constant.value == Py_Ellipsis) {
|
||||||
APPEND_STR_FINISH("...");
|
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);
|
return append_ast_constant(writer, e->v.Constant.value);
|
||||||
case JoinedStr_kind:
|
case JoinedStr_kind:
|
||||||
return append_joinedstr(writer, e, false);
|
return append_joinedstr(writer, e, false);
|
||||||
|
|
Loading…
Reference in New Issue