Avoid a glibc bug in test_time (issue #13309)
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 11 Nov 2011 02:04:35 +0000 (03:04 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 11 Nov 2011 02:04:35 +0000 (03:04 +0100)
Lib/test/test_time.py

index afdf43e55d372d589f606c26d3afee068d5fef1d..dd630bde243f4a47ad8981a6372238cfd8f5bc31 100644 (file)
@@ -5,6 +5,7 @@ import locale
 import sysconfig
 import sys
 import warnings
+import platform
 
 # Max year is only limited by the size of C int.
 SIZEOF_INT = sysconfig.get_config_var('SIZEOF_INT') or 4
@@ -313,13 +314,14 @@ class TimeTestCase(unittest.TestCase):
         # It may not be possible to reliably make mktime return error
         # on all platfom.  This will make sure that no other exception
         # than OverflowError is raised for an extreme value.
+        if platform.libc_ver()[0] == 'glibc':
+            # Issue #13309: passing extreme values to mktime() or localtime()
+            # borks the glibc's internal timezone data.
+            return
         try:
             time.mktime((-1, 1, 1, 0, 0, 0, -1, -1, -1))
         except OverflowError:
             pass
-        msg = "Issue #13309: the '%Z' specifier reports erroneous timezone"
-        msg += " after time.mktime((-1, 1, 1, 0, 0, 0, -1, -1, -1))."
-        self.assertEqual(time.strftime('%Z', tt), tzname, msg)
 
 
 class TestLocale(unittest.TestCase):