Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0a1d62

Browse files
committed
Avoid a glibc bug in test_time (issue #13309)
1 parent 44c6aff commit b0a1d62

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Lib/test/test_time.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sysconfig
66
import sys
77
import warnings
8+
import platform
89

910
# Max year is only limited by the size of C int.
1011
SIZEOF_INT = sysconfig.get_config_var('SIZEOF_INT') or 4
@@ -313,13 +314,14 @@ def test_zzz_mktime(self):
313314
# It may not be possible to reliably make mktime return error
314315
# on all platfom. This will make sure that no other exception
315316
# than OverflowError is raised for an extreme value.
317+
if platform.libc_ver()[0] == 'glibc':
318+
# Issue #13309: passing extreme values to mktime() or localtime()
319+
# borks the glibc's internal timezone data.
320+
return
316321
try:
317322
time.mktime((-1, 1, 1, 0, 0, 0, -1, -1, -1))
318323
except OverflowError:
319324
pass
320-
msg = "Issue #13309: the '%Z' specifier reports erroneous timezone"
321-
msg += " after time.mktime((-1, 1, 1, 0, 0, 0, -1, -1, -1))."
322-
self.assertEqual(time.strftime('%Z', tt), tzname, msg)
323325

324326

325327
class TestLocale(unittest.TestCase):

0 commit comments

Comments
 (0)