Commit 5692f740 authored by Stefan Behnel's avatar Stefan Behnel

fix error reporting position for illegal string escapes

parent 5cdb7ba3
...@@ -785,18 +785,17 @@ def p_string_literal(s, kind_override=None): ...@@ -785,18 +785,17 @@ def p_string_literal(s, kind_override=None):
if len(systr) == 4: if len(systr) == 4:
chars.append_charval( int(systr[2:], 16) ) chars.append_charval( int(systr[2:], 16) )
else: else:
s.error("Invalid hex escape '%s'" % systr, pos=s.position()) s.error("Invalid hex escape '%s'" % systr)
elif c in u'Uu': elif c in u'Uu':
if kind in ('u', ''): if kind in ('u', ''):
if len(systr) in (6,10): if len(systr) in (6,10):
chrval = int(systr[2:], 16) chrval = int(systr[2:], 16)
if chrval > 1114111: # sys.maxunicode: if chrval > 1114111: # sys.maxunicode:
s.error("Invalid unicode escape '%s'" % systr, s.error("Invalid unicode escape '%s'" % systr)
pos = pos)
else: else:
s.error("Invalid unicode escape '%s'" % systr, pos=s.position()) s.error("Invalid unicode escape '%s'" % systr)
else: else:
# unicode escapes in plain byte strings are not unescaped # unicode escapes in byte strings are not unescaped
chrval = None chrval = None
chars.append_uescape(chrval, systr) chars.append_uescape(chrval, systr)
else: else:
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
u'\u' u'\u'
_ERRORS = ''' _ERRORS = '''
2:1: Invalid unicode escape '\u' 2:2: Invalid unicode escape '\u'
''' '''
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
u'\u12' u'\u12'
_ERRORS = ''' _ERRORS = '''
2:1: Invalid unicode escape '\u' 2:2: Invalid unicode escape '\u'
''' '''
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment