mirror of
https://github.com/python/cpython.git
synced 2024-11-24 02:15:30 +08:00
bpo-37053: handle strings like u"bar" correctly in Tools/parser/unparse.py (GH-13583)
Constant.kind is added in https://bugs.python.org/issue36280. Current possible values for Constant.kind are "u" or None. For r'bar' and b'bar', Constant.kind value is None, so there's no need for special handling. https://bugs.python.org/issue37053
This commit is contained in:
parent
91f4380ced
commit
aaf47caf35
@ -139,6 +139,11 @@ class UnparseTestCase(ASTTestCase):
|
|||||||
self.check_roundtrip(r"""f'{f"{0}"*3}'""")
|
self.check_roundtrip(r"""f'{f"{0}"*3}'""")
|
||||||
self.check_roundtrip(r"""f'{f"{y}"*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):
|
def test_del_statement(self):
|
||||||
self.check_roundtrip("del x, y, z")
|
self.check_roundtrip("del x, y, z")
|
||||||
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
Handle strings like u"bar" correctly in Tools/parser/unparse.py. Patch by Chih-Hsuan Yen.
|
@ -399,6 +399,8 @@ class Unparser:
|
|||||||
elif value is ...:
|
elif value is ...:
|
||||||
self.write("...")
|
self.write("...")
|
||||||
else:
|
else:
|
||||||
|
if t.kind == "u":
|
||||||
|
self.write("u")
|
||||||
self._write_constant(t.value)
|
self._write_constant(t.value)
|
||||||
|
|
||||||
def _List(self, t):
|
def _List(self, t):
|
||||||
|
Loading…
Reference in New Issue
Block a user