diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-04-22 18:35:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 18:35:28 +0300 |
commit | 6ccfa31421393910b52936e0447625db06f2a655 (patch) | |
tree | 825f9f3bcd6c14f5bab82ee08d55988f8748a168 /Lib/re/_parser.py | |
parent | 2f233fceae9a0c5e66e439bc0169b36547ba47c3 (diff) | |
download | cpython-6ccfa31421393910b52936e0447625db06f2a655.tar.gz cpython-6ccfa31421393910b52936e0447625db06f2a655.zip |
gh-90568: Fix exception type for \N with a named sequence in RE (GH-91665)
re.error is now raised instead of TypeError.
Diffstat (limited to 'Lib/re/_parser.py')
-rw-r--r-- | Lib/re/_parser.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/re/_parser.py b/Lib/re/_parser.py index f191f809a14..65888624930 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 |