Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7afb766

Browse files
committed
#2541 Allow unicode escapes in raw strings
1 parent f95ecf7 commit 7afb766

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/test/test_unicode.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def test_literals(self):
6868
self.assertRaises(SyntaxError, eval, '\'\\Ufffffffe\'')
6969
self.assertRaises(SyntaxError, eval, '\'\\Uffffffff\'')
7070
self.assertRaises(SyntaxError, eval, '\'\\U%08x\'' % 0x110000)
71+
# Test that raw mode does unicode escapes
72+
self.assertEqual(r"\u0020", " ")
7173

7274
def test_repr(self):
7375
if not sys.platform.startswith('java'):

Python/ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,7 @@ parsestr(struct compiling *c, const node *n, int *bytesmode)
32313231
return NULL;
32323232
}
32333233
}
3234-
if (!*bytesmode && !rawmode) {
3234+
if (!*bytesmode) {
32353235
return decode_unicode(s, len, rawmode, c->c_encoding);
32363236
}
32373237
if (*bytesmode) {

0 commit comments

Comments
 (0)