|
15 | 15 | import random |
16 | 16 | import struct |
17 | 17 | import unittest |
18 | | -import sysconfig |
19 | 18 |
|
20 | 19 | from array import array |
21 | 20 |
|
@@ -4591,13 +4590,16 @@ def tzname(self, dt): |
4591 | 4590 | def zonenames(cls, zonedir=None): |
4592 | 4591 | if zonedir is None: |
4593 | 4592 | zonedir = cls.zoneroot |
4594 | | - for root, _, files in os.walk(zonedir): |
4595 | | - for f in files: |
4596 | | - p = os.path.join(root, f) |
4597 | | - with open(p, 'rb') as o: |
4598 | | - magic = o.read(4) |
4599 | | - if magic == b'TZif': |
4600 | | - yield p[len(zonedir) + 1:] |
| 4593 | + zone_tab = os.path.join(zonedir, 'zone.tab') |
| 4594 | + try: |
| 4595 | + f = open(zone_tab) |
| 4596 | + except OSError: |
| 4597 | + return |
| 4598 | + with f: |
| 4599 | + for line in f: |
| 4600 | + line = line.strip() |
| 4601 | + if line and not line.startswith('#'): |
| 4602 | + yield line.split()[2] |
4601 | 4603 |
|
4602 | 4604 | @classmethod |
4603 | 4605 | def stats(cls, start_year=1): |
@@ -4692,7 +4694,6 @@ class ZoneInfoTest(unittest.TestCase): |
4692 | 4694 | zonename = 'America/New_York' |
4693 | 4695 |
|
4694 | 4696 | def setUp(self): |
4695 | | - self.sizeof_time_t = sysconfig.get_config_var('SIZEOF_TIME_T') |
4696 | 4697 | if sys.platform == "win32": |
4697 | 4698 | self.skipTest("Skipping zoneinfo tests on Windows") |
4698 | 4699 | try: |
@@ -4765,12 +4766,11 @@ def test_system_transitions(self): |
4765 | 4766 | try: |
4766 | 4767 | _time.tzset() |
4767 | 4768 | for udt, shift in tz.transitions(): |
4768 | | - if self.zonename == 'Europe/Tallinn' and udt.date() == date(1999, 10, 31): |
| 4769 | + if (self.zonename == 'Europe/Tallinn' and udt.date() == date(1999, 10, 31) or |
| 4770 | + self.zonename.endswith(('Casablanca', 'El_Aaiun')) and |
| 4771 | + udt.date() == date(2037, 10, 4)): |
4769 | 4772 | print("Skip %s %s transition" % (self.zonename, udt)) |
4770 | 4773 | continue |
4771 | | - if self.sizeof_time_t == 4 and udt.year >= 2037: |
4772 | | - print("Skip %s %s transition for 32-bit time_t" % (self.zonename, udt)) |
4773 | | - continue |
4774 | 4774 | s0 = (udt - datetime(1970, 1, 1)) // SEC |
4775 | 4775 | ss = shift // SEC # shift seconds |
4776 | 4776 | for x in [-40 * 3600, -20*3600, -1, 0, |
|
0 commit comments