@@ -292,7 +292,7 @@ def test_strptime_exception_context(self):
292
292
# additional check for IndexError branch (issue #19545)
293
293
with self .assertRaises (ValueError ) as e :
294
294
_strptime ._strptime_time ('19' , '%Y %' )
295
- self .assertIs (e .exception .__suppress_context__ , True )
295
+ self .assertIsNone (e .exception .__context__ )
296
296
297
297
def test_unconverteddata (self ):
298
298
# Check ValueError is raised when there is unconverted data
@@ -485,12 +485,14 @@ def test_bad_timezone(self):
485
485
# id_ID, ms_MY.
486
486
# * Year is not included: ha_NG.
487
487
# * Use non-Gregorian calendar: lo_LA, thai, th_TH.
488
+ # On Windows: ar_IN, ar_SA, fa_IR, ps_AF.
488
489
#
489
490
# BUG: Generates regexp that does not match the current date and time
490
- # for az_IR, fa_IR, lzh_TW, my_MM, or_IN, shn_MM .
491
+ # for lzh_TW.
491
492
@run_with_locales ('LC_TIME' , 'C' , 'en_US' , 'fr_FR' , 'de_DE' , 'ja_JP' ,
492
493
'he_IL' , 'eu_ES' , 'ar_AE' , 'mfe_MU' , 'yo_NG' ,
493
- 'csb_PL' , 'br_FR' , 'gez_ET' , 'brx_IN' )
494
+ 'csb_PL' , 'br_FR' , 'gez_ET' , 'brx_IN' ,
495
+ 'my_MM' , 'or_IN' , 'shn_MM' , 'az_IR' )
494
496
def test_date_time_locale (self ):
495
497
# Test %c directive
496
498
loc = locale .getlocale (locale .LC_TIME )[0 ]
@@ -512,20 +514,23 @@ def test_date_time_locale(self):
512
514
self .roundtrip ('%c' , slice (0 , 6 ), time .localtime (now - 366 * 24 * 3600 ))
513
515
514
516
# NB: Dates before 1969 do not roundtrip on some locales:
515
- # bo_CN, bo_IN, dz_BT, eu_ES, eu_FR.
517
+ # az_IR, bo_CN, bo_IN, dz_BT, eu_ES, eu_FR, fa_IR, or_IN .
516
518
@run_with_locales ('LC_TIME' , 'C' , 'en_US' , 'fr_FR' , 'de_DE' , 'ja_JP' ,
517
519
'he_IL' , 'ar_AE' , 'mfe_MU' , 'yo_NG' ,
518
- 'csb_PL' , 'br_FR' , 'gez_ET' , 'brx_IN' )
520
+ 'csb_PL' , 'br_FR' , 'gez_ET' , 'brx_IN' ,
521
+ 'my_MM' , 'shn_MM' )
519
522
def test_date_time_locale2 (self ):
520
523
# Test %c directive
521
524
self .roundtrip ('%c' , slice (0 , 6 ), (1900 , 1 , 1 , 0 , 0 , 0 , 0 , 1 , 0 ))
525
+ self .roundtrip ('%c' , slice (0 , 6 ), (1800 , 1 , 1 , 0 , 0 , 0 , 0 , 1 , 0 ))
522
526
523
527
# NB: Does not roundtrip because use non-Gregorian calendar:
524
- # lo_LA, thai, th_TH.
528
+ # lo_LA, thai, th_TH. On Windows: ar_IN, ar_SA, fa_IR, ps_AF.
525
529
# BUG: Generates regexp that does not match the current date
526
- # for az_IR, fa_IR, lzh_TW, my_MM, or_IN, shn_MM .
530
+ # for lzh_TW.
527
531
@run_with_locales ('LC_TIME' , 'C' , 'en_US' , 'fr_FR' , 'de_DE' , 'ja_JP' ,
528
- 'he_IL' , 'eu_ES' , 'ar_AE' )
532
+ 'he_IL' , 'eu_ES' , 'ar_AE' ,
533
+ 'az_IR' , 'my_MM' , 'or_IN' , 'shn_MM' )
529
534
def test_date_locale (self ):
530
535
# Test %x directive
531
536
now = time .time ()
@@ -545,30 +550,39 @@ def test_date_locale(self):
545
550
"musl libc issue on Emscripten, bpo-46390"
546
551
)
547
552
@run_with_locales ('LC_TIME' , 'en_US' , 'fr_FR' , 'de_DE' , 'ja_JP' ,
548
- 'eu_ES' , 'ar_AE' )
553
+ 'eu_ES' , 'ar_AE' , 'my_MM' , 'shn_MM' )
549
554
def test_date_locale2 (self ):
550
555
# Test %x directive
551
556
self .roundtrip ('%x' , slice (0 , 3 ), (1900 , 1 , 1 , 0 , 0 , 0 , 0 , 1 , 0 ))
557
+ self .roundtrip ('%x' , slice (0 , 3 ), (1800 , 1 , 1 , 0 , 0 , 0 , 0 , 1 , 0 ))
552
558
553
559
# NB: Does not roundtrip in some locales due to the ambiguity of
554
560
# the time representation (bugs in locales?):
555
561
# * Seconds are not included: bokmal, ff_SN, nb_NO, nn_NO, no_NO,
556
562
# norwegian, nynorsk.
557
563
# * Hours are in 12-hour notation without AM/PM indication: hy_AM,
558
564
# ms_MY, sm_WS.
559
- # BUG: Generates regexp that does not match the current time for
560
- # aa_DJ, aa_ER, aa_ET, am_ET, az_IR, byn_ER, fa_IR, gez_ER, gez_ET ,
561
- # lzh_TW, my_MM, om_ET, om_KE, or_IN, shn_MM, sid_ET, so_DJ, so_ET ,
562
- # so_SO, ti_ER, ti_ET, tig_ER, wal_ET.
563
- @ run_with_locales ( 'LC_TIME' , 'C' , 'en_US' , 'fr_FR ' , 'de_DE ' , 'ja_JP ' )
565
+ # BUG: Generates regexp that does not match the current time for lzh_TW.
566
+ @ run_with_locales ( 'LC_TIME' , 'C' , 'en_US' , 'fr_FR' , 'de_DE' , 'ja_JP' ,
567
+ 'aa_ET' , 'am_ET' , 'az_IR' , 'byn_ER' , 'fa_IR' , 'gez_ET' ,
568
+ 'my_MM' , 'om_ET' , 'or_IN' , 'shn_MM' , 'sid_ET' , 'so_SO' ,
569
+ 'ti_ET ' , 'tig_ER ' , 'wal_ET ' )
564
570
def test_time_locale (self ):
565
571
# Test %X directive
572
+ loc = locale .getlocale (locale .LC_TIME )[0 ]
573
+ pos = slice (3 , 6 )
574
+ if glibc_ver and glibc_ver < (2 , 29 ) and loc in {
575
+ 'aa_ET' , 'am_ET' , 'byn_ER' , 'gez_ET' , 'om_ET' ,
576
+ 'sid_ET' , 'so_SO' , 'ti_ET' , 'tig_ER' , 'wal_ET' }:
577
+ # Hours are in 12-hour notation without AM/PM indication.
578
+ # Ignore hours.
579
+ pos = slice (4 , 6 )
566
580
now = time .time ()
567
- self .roundtrip ('%X' , slice ( 3 , 6 ) , time .localtime (now ))
581
+ self .roundtrip ('%X' , pos , time .localtime (now ))
568
582
# 1 hour 20 minutes 30 seconds ago
569
- self .roundtrip ('%X' , slice ( 3 , 6 ) , time .localtime (now - 4830 ))
583
+ self .roundtrip ('%X' , pos , time .localtime (now - 4830 ))
570
584
# 12 hours ago
571
- self .roundtrip ('%X' , slice ( 3 , 6 ) , time .localtime (now - 12 * 3600 ))
585
+ self .roundtrip ('%X' , pos , time .localtime (now - 12 * 3600 ))
572
586
573
587
def test_percent (self ):
574
588
# Make sure % signs are handled properly
0 commit comments