[Python-checkins] cpython: Issue #25168: Temporary timezone and cache debugging

martin.panter python-checkins at python.org
Sat Nov 14 03:55:34 EST 2015


https://hg.python.org/cpython/rev/139c18943d9b
changeset:   99131:139c18943d9b
user:        Martin Panter <vadmium+py at gmail.com>
date:        Sat Nov 14 08:54:30 2015 +0000
summary:
  Issue #25168: Temporary timezone and cache debugging

files:
  Lib/test/datetimetester.py |  11 ++++++++++-
  1 files changed, 10 insertions(+), 1 deletions(-)


diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -1979,7 +1979,16 @@
                 seconds = tzseconds
             hours, minutes = divmod(seconds//60, 60)
             dtstr = "{}{:02d}{:02d} {}".format(sign, hours, minutes, tzname)
-            dt = strptime(dtstr, "%z %Z")
+            try:
+                dt = strptime(dtstr, "%z %Z")
+            except ValueError:
+                import os
+                self.fail(
+                    "Issue #25168 strptime() failure info:\n"
+                    f"_TimeRE_cache['Z']={_strptime._TimeRE_cache['Z']!r}\n"
+                    f"TZ={os.environ.get('TZ')!r}, or {os.getenv('TZ')!r} via getenv()\n"
+                    f"_regex_cache={_strptime._regex_cache!r}\n"
+                )
             self.assertEqual(dt.utcoffset(), timedelta(seconds=tzseconds))
             self.assertEqual(dt.tzname(), tzname)
         # Can produce inconsistent datetime

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list