Issue 25168: test_datetime.test_strptime() random failures on "s390x SLES" buildbots (original) (raw)

Created on 2015-09-18 13:50 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
strptime_cache_timezone.patch serhiy.storchaka,2015-11-14 16:26 review
Messages (7)
msg250987 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-09-18 13:50
It looks like the failure is random. It probably depends on the test order. http://buildbot.python.org/all/builders/s390x%20SLES%203.4/builds/45/steps/test/logs/stdio ====================================================================== ERROR: test_strptime (test.datetimetester.TestDateTimeTZ_Pure) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/test/datetimetester.py", line 1941, in test_strptime dt = strptime(dtstr, "%z %Z") File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/datetime.py", line 1607, in strptime return _strptime._strptime_datetime(cls, date_string, format) File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/_strptime.py", line 500, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/_strptime.py", line 337, in _strptime (data_string, format)) ValueError: time data '-0500 EST' does not match format '%z %Z' ====================================================================== ERROR: test_strptime (test.datetimetester.TestDateTime_Pure) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/test/datetimetester.py", line 1941, in test_strptime dt = strptime(dtstr, "%z %Z") File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/datetime.py", line 1607, in strptime return _strptime._strptime_datetime(cls, date_string, format) File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/_strptime.py", line 500, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/_strptime.py", line 337, in _strptime (data_string, format)) ValueError: time data '-0500 EST' does not match format '%z %Z' ====================================================================== ERROR: test_strptime (test.datetimetester.TestSubclassDateTime_Pure) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/test/datetimetester.py", line 1941, in test_strptime dt = strptime(dtstr, "%z %Z") File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/datetime.py", line 1607, in strptime return _strptime._strptime_datetime(cls, date_string, format) File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/_strptime.py", line 500, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "/home/dje/cpython-buildarea/3.4.edelsohn-sles-z/build/Lib/_strptime.py", line 337, in _strptime (data_string, format)) ValueError: time data '-0500 EST' does not match format '%z %Z'
msg251005 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-09-18 15:26
Perhaps related issues: , , , .
msg254643 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-11-14 08:02
I wonder if this has anything to do with _strptime._TimeRE_cache. This seems to get initialized when _strptime is first imported. Some of the tests in datetimetester temporarily set the timezone to -0500 EST, and another to UTC, but they change it back afterwards. So I cannot see how it could have an effect, but I don’t have a better theory. >>> import _strptime # Regular expression cache is initialized >>> _strptime._TimeRE_cache["Z"] # I don't have a time zone set '(?Pgmt|utc)' >>> import os, time >>> os.environ["TZ"] = 'EST+05EDT,M3.2.0,M11.1.0' >>> time.tzset() >>> time.tzname ('EST', 'EDT') >>> from datetime import datetime >>> datetime.strptime("-0500 EST", "%z %Z") # Using original cache Traceback (most recent call last): File "", line 1, in File "/home/proj/python/cpython/Lib/_strptime.py", line 555, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "/home/proj/python/cpython/Lib/_strptime.py", line 356, in _strptime (data_string, format)) ValueError: time data '-0500 EST' does not match format '%z %Z'
msg254646 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-11-14 08:55
New changeset 139c18943d9b by Martin Panter in branch 'default': Issue #25168: Temporary timezone and cache debugging https://hg.python.org/cpython/rev/139c18943d9b
msg254657 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-11-14 13:34
Info when the s390x SLES 3.x buildbot failed <http://buildbot.python.org/all/builders/s390x%20SLES%203.x/builds/414/steps/test/logs/stdio>: _TimeRE_cache['Z']='(?Pstd|utc gmt dst)' TZ=None, or None via getenv() _regex_cache={'%Y-%m-%d %H:%M:%S.%f': re.compile('(?P\\d\\d\\d\\d)-(?P1[0-2]
msg254663 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-11-14 16:26
Thanks to Martin's research I have wrote a patch that resets a cache when timezone is changed. Martin's example in works with this patch.
msg254677 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-11-15 00:58
I just discovered Issue 20220 about a similar story with a tarfile test case. It looks like this is caused by the same underlying C library quirk, so I am closing this as a duplicate. Using Antoine’s reproducer there I triggered both this datetime failure and the tarfile failure: TZ='America/New_York' ./python -m test -v test_imaplib test_tarfile test_datetime Also Serhiy I discovered Issue 6478 about the strptime() cache which has patches trying to do a similar thing to your patch.
History
Date User Action Args
2022-04-11 14:58:21 admin set github: 69355
2015-11-15 00:58:41 martin.panter set status: open -> closedsuperseder: test_datetime, test_tarfile, test_strptime time zone failuresresolution: duplicatemessages: +
2015-11-14 16:26:55 serhiy.storchaka set files: + strptime_cache_timezone.patchkeywords: + patchmessages: +
2015-11-14 14:25:58 serhiy.storchaka set nosy: + David.Edelsohn
2015-11-14 13:34:34 martin.panter set messages: +
2015-11-14 08:55:36 python-dev set nosy: + python-devmessages: +
2015-11-14 08:02:38 martin.panter set nosy: + martin.pantermessages: + components: + Teststype: behavior
2015-09-18 15:26:49 serhiy.storchaka set messages: +
2015-09-18 13:50:48 vstinner create