Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/test/test_tools/test_unparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ def test_fstrings(self):
self.check_roundtrip(r"""f'{f"{0}"*3}'""")
self.check_roundtrip(r"""f'{f"{y}"*3}'""")

def test_strings(self):
self.check_roundtrip("u'foo'")
self.check_roundtrip("r'foo'")
self.check_roundtrip("b'foo'")

def test_del_statement(self):
self.check_roundtrip("del x, y, z")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle strings like u"bar" correctly in Tools/parser/unparse.py. Patch by Chih-Hsuan Yen.
2 changes: 2 additions & 0 deletions Tools/parser/unparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ def _Constant(self, t):
elif value is ...:
self.write("...")
else:
if t.kind == "u":
self.write("u")
self._write_constant(t.value)

def _List(self, t):
Expand Down