From a783d06f8cb4077dd34567fde418bf6c23073912 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Thu, 15 Sep 2005 02:34:56 +0000 Subject: Clear out the regex cache when the TimeRE cache is invalidated by a locale change. Fixes bug #1290505. --- Lib/_strptime.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Lib/_strptime.py') diff --git a/Lib/_strptime.py b/Lib/_strptime.py index 90928ffca8..08d79603a0 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) -- cgit v1.2.1