#2541 Allow unicode escapes in raw strings

This commit is contained in:
Benjamin Peterson 2008-04-03 16:27:27 +00:00
parent f95ecf7b15
commit 7afb766c5d
2 changed files with 3 additions and 1 deletions

View file

@ -68,6 +68,8 @@ class UnicodeTest(
self.assertRaises(SyntaxError, eval, '\'\\Ufffffffe\'') self.assertRaises(SyntaxError, eval, '\'\\Ufffffffe\'')
self.assertRaises(SyntaxError, eval, '\'\\Uffffffff\'') self.assertRaises(SyntaxError, eval, '\'\\Uffffffff\'')
self.assertRaises(SyntaxError, eval, '\'\\U%08x\'' % 0x110000) self.assertRaises(SyntaxError, eval, '\'\\U%08x\'' % 0x110000)
# Test that raw mode does unicode escapes
self.assertEqual(r"\u0020", " ")
def test_repr(self): def test_repr(self):
if not sys.platform.startswith('java'): if not sys.platform.startswith('java'):

View file

@ -3231,7 +3231,7 @@ parsestr(struct compiling *c, const node *n, int *bytesmode)
return NULL; return NULL;
} }
} }
if (!*bytesmode && !rawmode) { if (!*bytesmode) {
return decode_unicode(s, len, rawmode, c->c_encoding); return decode_unicode(s, len, rawmode, c->c_encoding);
} }
if (*bytesmode) { if (*bytesmode) {