summaryrefslogtreecommitdiffstats
path: root/Lib/re/_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/re/_parser.py')
-rw-r--r--Lib/re/_parser.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/re/_parser.py b/Lib/re/_parser.py
index f191f80..6588862 100644
--- a/Lib/re/_parser.py
+++ b/Lib/re/_parser.py
@@ -333,7 +333,7 @@ def _class_escape(source, escape):
charname = source.getuntil('}', 'character name')
try:
c = ord(unicodedata.lookup(charname))
- except KeyError:
+ except (KeyError, TypeError):
raise source.error("undefined character name %r" % charname,
len(charname) + len(r'\N{}')) from None
return LITERAL, c
@@ -393,7 +393,7 @@ def _escape(source, escape, state):
charname = source.getuntil('}', 'character name')
try:
c = ord(unicodedata.lookup(charname))
- except KeyError:
+ except (KeyError, TypeError):
raise source.error("undefined character name %r" % charname,
len(charname) + len(r'\N{}')) from None
return LITERAL, c