summaryrefslogtreecommitdiffstats
path: root/Lib/_strptime.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2005-09-15 02:34:56 (GMT)
committerBrett Cannon <bcannon@gmail.com>2005-09-15 02:34:56 (GMT)
commita783d06f8cb4077dd34567fde418bf6c23073912 (patch)
tree5b8fd68bf9715fdb363227fce18d6bf77e71f19d /Lib/_strptime.py
parentfb1ef85b0bbb6336e03489af7adaff494bd2b2bb (diff)
downloadcpython-a783d06f8cb4077dd34567fde418bf6c23073912.zip
cpython-a783d06f8cb4077dd34567fde418bf6c23073912.tar.gz
cpython-a783d06f8cb4077dd34567fde418bf6c23073912.tar.bz2
Clear out the regex cache when the TimeRE cache is invalidated by a locale
change. Fixes bug #1290505.
Diffstat (limited to 'Lib/_strptime.py')
-rw-r--r--Lib/_strptime.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
index 90928ff..08d7960 100644
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -275,13 +275,14 @@ _regex_cache = {}
def strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
"""Return a time struct based on the input string and the format string."""
- global _TimeRE_cache
+ global _TimeRE_cache, _regex_cache
_cache_lock.acquire()
try:
time_re = _TimeRE_cache
locale_time = time_re.locale_time
if _getlang() != locale_time.lang:
_TimeRE_cache = TimeRE()
+ _regex_cache = {}
if len(_regex_cache) > _CACHE_MAX_SIZE:
_regex_cache.clear()
format_regex = _regex_cache.get(format)