[Python-checkins] r53590 - python/trunk/Lib/_strptime.py
brett.cannon
python-checkins at python.org
Sun Jan 28 21:58:01 CET 2007
Author: brett.cannon
Date: Sun Jan 28 21:58:00 2007
New Revision: 53590
Modified:
python/trunk/Lib/_strptime.py
Log:
Use the thread lock's context manager instead of a try/finally statement.
Modified: python/trunk/Lib/_strptime.py
==============================================================================
--- python/trunk/Lib/_strptime.py (original)
+++ python/trunk/Lib/_strptime.py Sun Jan 28 21:58:00 2007
@@ -294,8 +294,7 @@
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, _regex_cache
- _cache_lock.acquire()
- try:
+ with _cache_lock:
time_re = _TimeRE_cache
locale_time = time_re.locale_time
if _getlang() != locale_time.lang:
@@ -320,8 +319,6 @@
except IndexError:
raise ValueError("stray %% in format '%s'" % format)
_regex_cache[format] = format_regex
- finally:
- _cache_lock.release()
found = format_regex.match(data_string)
if not found:
raise ValueError("time data %r does not match format %r" %
More information about the Python-checkins
mailing list