summaryrefslogtreecommitdiffstats
path: root/Lib/re.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-10-30 23:31:33 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-10-30 23:31:33 (GMT)
commite969b1b80ecfcf3de576a46ff168ccd08767b999 (patch)
tree4a2e1a3c22121ed6f799a45f13ce5b890e30ff35 /Lib/re.py
parentd4c7290368a82a265c9905dc5c1e95591fb96333 (diff)
downloadcpython-e969b1b80ecfcf3de576a46ff168ccd08767b999.zip
cpython-e969b1b80ecfcf3de576a46ff168ccd08767b999.tar.gz
cpython-e969b1b80ecfcf3de576a46ff168ccd08767b999.tar.bz2
Fixed compile error in issue #22410. The _locale module is optional.
Diffstat (limited to 'Lib/re.py')
-rw-r--r--Lib/re.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/re.py b/Lib/re.py
index a82a446..671a904 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -104,7 +104,10 @@ This module also defines an exception 'error'.
import sys
import sre_compile
import sre_parse
-import _locale
+try:
+ import _locale
+except ImportError:
+ _locale = None
# public symbols
__all__ = [ "match", "search", "sub", "subn", "split", "findall",
@@ -250,6 +253,8 @@ def _compile(*key):
if len(_cache) >= _MAXCACHE:
_cache.clear()
if p.flags & LOCALE:
+ if not _locale:
+ return p
loc = _locale.setlocale(_locale.LC_CTYPE)
else:
loc = None