[issue6478] time.tzset does not reset _strptime's locale time cache
Berker Peksag
report at bugs.python.org
Sat Feb 9 02:45:15 CET 2013
Berker Peksag added the comment:
> There is a long line in _strptime.py which I will fix before
> committing.
Ops, fixed.
Also, I've found a better place for the test in Lib/test/test_strptime.py
and moved it to the test_strptime.CacheTests.
When I applied the patch, test_bad_timezone test failed because of
this code in Lib/_strptime.py:
@staticmethod
def _get_timezone():
try:
time.tzset()
except AttributeError:
pass
# ...
time.tzset() always resets time.tzname[1], so this part of the code
in test_bad_timezone[2] didn't work.
tzname = time.tzname[0]
time.tzname = (tzname, tzname)
I've fixed test_bad_timezone test by mocking the new
_strptime._TimeRE_cache.locale_time._get_timezone method.
[1] http://hg.python.org/cpython/file/default/Modules/timemodule.c#l827
[2] http://hg.python.org/cpython/file/default/Lib/test/test_strptime.py#l320
----------
Added file: http://bugs.python.org/file29012/issue6478_v3.diff
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6478>
_______________________________________
More information about the Python-bugs-list
mailing list