diff options
-rw-r--r-- | Lib/test/test_future.py | 1 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2020-04-14-18-47-00.bpo-39522.uVeIV_.rst | 2 | ||||
-rw-r--r-- | Python/ast_unparse.c | 2 |
3 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py index ebeb833..0522003 100644 --- a/Lib/test/test_future.py +++ b/Lib/test/test_future.py @@ -153,6 +153,7 @@ class AnnotationsFutureTestCase(unittest.TestCase): eq = self.assertAnnotationEqual eq('...') eq("'some_string'") + eq("u'some_string'") eq("b'\\xa3'") eq('Name') eq('None') diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-04-14-18-47-00.bpo-39522.uVeIV_.rst b/Misc/NEWS.d/next/Core and Builtins/2020-04-14-18-47-00.bpo-39522.uVeIV_.rst new file mode 100644 index 0000000..12d939d --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-04-14-18-47-00.bpo-39522.uVeIV_.rst @@ -0,0 +1,2 @@ +Correctly unparse explicit ``u`` prefix for strings when postponed +evaluation for annotations activated. Patch by Batuhan Taskaya. diff --git a/Python/ast_unparse.c b/Python/ast_unparse.c index 7cf199b..c321acf 100644 --- a/Python/ast_unparse.c +++ b/Python/ast_unparse.c @@ -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); |