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