diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-05-05 05:53:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-05 05:53:40 (GMT) |
commit | 898ff03e1e7925ecde3da66327d3cdc7e07625ba (patch) | |
tree | 977fc4b98c0e85816348cebd3b12026407c368b6 /Lib/re.py | |
parent | 647c3d381e67490e82cdbbe6c96e46d5e1628ce2 (diff) | |
download | cpython-898ff03e1e7925ecde3da66327d3cdc7e07625ba.zip cpython-898ff03e1e7925ecde3da66327d3cdc7e07625ba.tar.gz cpython-898ff03e1e7925ecde3da66327d3cdc7e07625ba.tar.bz2 |
bpo-30215: Make re.compile() locale agnostic. (#1361)
Compiled regular expression objects with the re.LOCALE flag no longer
depend on the locale at compile time. Only the locale at matching
time affects the result of matching.
Diffstat (limited to 'Lib/re.py')
-rw-r--r-- | Lib/re.py | 12 |
1 files changed, 2 insertions, 10 deletions
@@ -268,9 +268,7 @@ _MAXCACHE = 512 def _compile(pattern, flags): # internal: compile pattern try: - p, loc = _cache[type(pattern), pattern, flags] - if loc is None or loc == _locale.setlocale(_locale.LC_CTYPE): - return p + return _cache[type(pattern), pattern, flags] except KeyError: pass if isinstance(pattern, _pattern_type): @@ -284,13 +282,7 @@ def _compile(pattern, flags): if not (flags & DEBUG): if len(_cache) >= _MAXCACHE: _cache.clear() - if p.flags & LOCALE: - if not _locale: - return p - loc = _locale.setlocale(_locale.LC_CTYPE) - else: - loc = None - _cache[type(pattern), pattern, flags] = p, loc + _cache[type(pattern), pattern, flags] = p return p @functools.lru_cache(_MAXCACHE) |