From: Serhiy Storchaka Date: Thu, 30 Oct 2014 23:34:45 +0000 (+0200) Subject: Fixed compile error in issue #22410. The _locale module is optional. X-Git-Tag: v3.4.3rc1~389 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cf7b1cadd19762f63cff48713b5be7b0dd3f548e;p=thirdparty%2FPython%2Fcpython.git Fixed compile error in issue #22410. The _locale module is optional. --- diff --git a/Lib/re.py b/Lib/re.py index 46cea2bd691f..199afee4b904 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__ = [ "match", "fullmatch", "search", "sub", "subn", "split", "findall", @@ -293,6 +296,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