summaryrefslogtreecommitdiffstats
path: root/Lib/re.py
diff options
context:
space:
mode:
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 e731a69..0b1cb46 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -122,7 +122,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__ = [
@@ -292,6 +295,8 @@ def _compile(pattern, flags):
if len(_cache) >= _MAXCACHE:
_cache.clear()
if p.flags & LOCALE:
+ if not _locale:
+ return p
loc = _locale.setlocale(_locale.LC_CTYPE)
else:
loc = None