elif c == u'\n':
pass
elif c == u'x':
- chars.append_charval( int(systr[2:], 16) )
+ if len(systr) == 4:
+ chars.append_charval( int(systr[2:], 16) )
+ else:
+ s.error("Invalid hex escape '%s'" % systr, pos=s.position())
elif c in u'Uu':
if kind in ('u', ''):
- chrval = int(systr[2:], 16)
- if chrval > 1114111: # sys.maxunicode:
- s.error("Invalid unicode escape '%s'" % systr,
- pos = pos)
+ if len(systr) in (6,10):
+ chrval = int(systr[2:], 16)
+ if chrval > 1114111: # sys.maxunicode:
+ s.error("Invalid unicode escape '%s'" % systr,
+ pos = pos)
+ else:
+ s.error("Invalid unicode escape '%s'" % systr, pos=s.position())
else:
# unicode escapes in plain byte strings are not unescaped
chrval = None
>>> len(uresc)
9
+ >>> bytes_uescape
+ b'\\u1234\\U12345678\\u\\u1\\u12\\uX'
+ >>> bytes_uescape == b'\\u1234\\U12345678\\u\\u1\\u12\\uX'
+ True
+ >>> len(bytes_uescape)
+ 28
+
>>> newlines == "Aaa\n"
True
bresc = br'\12\'\"\\'
uresc = ur'\12\'\"\\'
+bytes_uescape = b'\u1234\U12345678\u\u1\u12\uX'
+
newlines = "Aaa\n"
# T640, long literals with escapes