c = ord(unicodedata.lookup(charname))
except KeyError:
raise source.error("undefined character name %r" % charname,
- len(charname) + len(r'\N{}'))
+ len(charname) + len(r'\N{}')) from None
return LITERAL, c
elif c in OCTDIGITS:
# octal escape (up to three digits)
c = ord(unicodedata.lookup(charname))
except KeyError:
raise source.error("undefined character name %r" % charname,
- len(charname) + len(r'\N{}'))
+ len(charname) + len(r'\N{}')) from None
return LITERAL, c
elif c == "0":
# octal escape
try:
index = groupindex[name]
except KeyError:
- raise IndexError("unknown group name %r" % name)
+ raise IndexError("unknown group name %r" % name) from None
else:
try:
index = int(name)
this = chr(ESCAPES[this][1])
except KeyError:
if c in ASCIILETTERS:
- raise s.error('bad escape %s' % this, len(this))
+ raise s.error('bad escape %s' % this, len(this)) from None
lappend(this)
else:
lappend(this)
for index, group in groups:
literals[index] = g(group) or empty
except IndexError:
- raise error("invalid group reference %d" % index)
+ raise error("invalid group reference %d" % index) from None
return empty.join(literals)