Skip to content

Commit b7251ab

Browse files
committed
Use CRT functions for time module on Windows
- Replace chrono with CRT functions (wcsftime, _gmtime64_s, _localtime64_s, _mktime64) on Windows for correct behavior - Fix timezone name corruption: use take_while instead of filter for null-terminated wide strings in TIME_ZONE_INFORMATION - Fix wcsftime symbol name (_wcsftime -> wcsftime) - Fix CString import cfg to unix-only - Remove 13 expectedFailure markers from test_time for Windows
1 parent 426019e commit b7251ab

2 files changed

Lines changed: 398 additions & 196 deletions

File tree

Lib/test/test_time.py

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ def test_strftime_invalid_format(self):
208208
except ValueError as exc:
209209
self.assertEqual(str(exc), 'Invalid format string')
210210

211-
# TODO: RUSTPYTHON; chrono fallback on Windows does not preserve surrogates
212-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
213211
def test_strftime_special(self):
214212
tt = time.gmtime(self.t)
215213
s1 = time.strftime('%c', tt)
@@ -294,8 +292,6 @@ def _bounds_checking(self, func):
294292
self.assertRaises(ValueError, func,
295293
(1900, 1, 1, 0, 0, 0, 0, 367, -1))
296294

297-
# TODO: RUSTPYTHON; chrono on Windows rejects month=0/day=0 and raises wrong error type
298-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
299295
def test_strftime_bounding_check(self):
300296
self._bounds_checking(lambda tup: time.strftime('', tup))
301297

@@ -312,8 +308,6 @@ def test_strftime_format_check(self):
312308
except ValueError:
313309
pass
314310

315-
# TODO: RUSTPYTHON; chrono on Windows does not handle month=0/day=0 in struct_time
316-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
317311
def test_default_values_for_zero(self):
318312
# Make sure that using all zeros uses the proper default
319313
# values. No test for daylight savings since strftime() does
@@ -324,8 +318,6 @@ def test_default_values_for_zero(self):
324318
result = time.strftime("%Y %m %d %H %M %S %w %j", (2000,)+(0,)*8)
325319
self.assertEqual(expected, result)
326320

327-
# TODO: RUSTPYTHON; chrono %Z on Windows not compatible with strptime
328-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
329321
@skip_if_buggy_ucrt_strfptime
330322
def test_strptime(self):
331323
# Should be able to go round-trip from strftime to strptime without
@@ -382,13 +374,9 @@ def test_asctime(self):
382374
self.assertRaises(TypeError, time.asctime, ())
383375
self.assertRaises(TypeError, time.asctime, (0,) * 10)
384376

385-
# TODO: RUSTPYTHON; chrono on Windows rejects month=0/day=0
386-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
387377
def test_asctime_bounding_check(self):
388378
self._bounds_checking(time.asctime)
389379

390-
# TODO: RUSTPYTHON; chrono on Windows formats negative years differently
391-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
392380
def test_ctime(self):
393381
t = time.mktime((1973, 9, 16, 1, 3, 52, 0, 0, -1))
394382
self.assertEqual(time.ctime(t), 'Sun Sep 16 01:03:52 1973')
@@ -761,37 +749,13 @@ def test_negative(self):
761749

762750

763751
class TestAsctime4dyear(_TestAsctimeYear, _Test4dYear, unittest.TestCase):
764-
# TODO: RUSTPYTHON; chrono on Windows cannot handle month=0/day=0 in struct_time
765-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
766-
def test_year(self, *args, **kwargs):
767-
return super().test_year(*args, **kwargs)
768-
769-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
770-
def test_large_year(self):
771-
return super().test_large_year()
772-
773-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
774-
def test_negative(self):
775-
return super().test_negative()
752+
pass
776753

777754
class TestStrftime4dyear(_TestStrftimeYear, _Test4dYear, unittest.TestCase):
778-
# TODO: RUSTPYTHON; chrono on Windows cannot handle month=0/day=0 in struct_time
779-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
780-
def test_year(self, *args, **kwargs):
781-
return super().test_year(*args, **kwargs)
782-
783-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
784-
def test_large_year(self):
785-
return super().test_large_year()
786-
787-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
788-
def test_negative(self):
789-
return super().test_negative()
755+
pass
790756

791757

792758
class TestPytime(unittest.TestCase):
793-
# TODO: RUSTPYTHON; chrono %Z on Windows gives offset instead of timezone name
794-
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
795759
@skip_if_buggy_ucrt_strfptime
796760
@unittest.skipUnless(time._STRUCT_TM_ITEMS == 11, "needs tm_zone support")
797761
def test_localtime_timezone(self):

0 commit comments

Comments
 (0)