summaryrefslogtreecommitdiffstats
path: root/Lib/sre_parse.py
diff options
context:
space:
mode:
authorZhou Fangyi <fangyi.zhou@yuriko.moe>2018-02-10 06:59:29 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-02-10 06:59:29 (GMT)
commit5df5286abda57a0b3865d4fc3e25aaf1a820ef49 (patch)
treee12b88d17b4505bba6d3fb320a4207d9a134c671 /Lib/sre_parse.py
parenta445feb72902e4a3c5ae712f0c289309e1580d52 (diff)
downloadcpython-5df5286abda57a0b3865d4fc3e25aaf1a820ef49.zip
cpython-5df5286abda57a0b3865d4fc3e25aaf1a820ef49.tar.gz
cpython-5df5286abda57a0b3865d4fc3e25aaf1a820ef49.tar.bz2
bpo-30688: Import unicodedata only when needed. (GH-5606)
Importing unicodedata in sre_parse leads to failure in compilation. unicodedata is unused during compilation, and is not compiled when this file is imported. The error occurs when generating posix variables, pprint is required. The dependency chain goes on like this: sysconfig -> pprint -> re -> sre_compile -> sre_parse (this file) This commits fixes compilation issues introduced by 2272cec13b53c405d86c45d404f035f201c0baef. (Issue 30688, GH-5588)
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r--Lib/sre_parse.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index db01e84..7a172ff 100644
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -13,7 +13,6 @@
# XXX: show string offset and offending character for all errors
from sre_constants import *
-import unicodedata
SPECIAL_CHARS = ".\\[{()*+?^$|"
REPEAT_CHARS = "*+?{"
@@ -324,6 +323,7 @@ def _class_escape(source, escape):
chr(c) # raise ValueError for invalid code
return LITERAL, c
elif c == "N" and source.istext:
+ import unicodedata
# named unicode escape e.g. \N{EM DASH}
if not source.match('{'):
raise source.error("missing {")
@@ -383,6 +383,7 @@ def _escape(source, escape, state):
chr(c) # raise ValueError for invalid code
return LITERAL, c
elif c == "N" and source.istext:
+ import unicodedata
# named unicode escape e.g. \N{EM DASH}
if not source.match('{'):
raise source.error("missing {")