@@ -2107,8 +2107,8 @@ def test_fromisoformat_fails(self):
21072107 '2020-W25-0' , # Invalid day-of-week
21082108 '2020-W25-8' , # Invalid day-of-week
21092109 # gh-152204: each fixed-width field must be exactly N ASCII digits
2110- '2020+12' , # '+' accepted in a basic-format field
2111- '2020 12' , # space accepted in a basic-format field
2110+ '2020+12' , # '+' in a basic-format field
2111+ '2020 12' , # space in a basic-format field
21122112 '+020-06-15' , # leading sign in the year
21132113 '202012+9' , # '+' in the day field
21142114 '2020-W 5' , # space in the week day-of-week field
@@ -3766,9 +3766,19 @@ def test_fromisoformat_fails_datetime(self):
37663766 '2009-04-19T12:30:45-00:90:00' , # Time zone field out from range
37673767 '2009-04-19T12:30:45-00:00:90' , # Time zone field out from range
37683768 '2020-2020' , # Ambiguous 9-char date portion
3769- '2009-04-19T12:30:4٥' , # Unicode digit in the seconds
3770- '20201212T0102٣٤' , # Unicode digits in the time (gh-152204)
3771- '2009-04-19T12:30:45+0٥:00' , # Unicode digit in the timezone
3769+ # gh-152204: each time field must be exactly N ASCII digits
3770+ '2020-12-12T0٥:02:03' , # Unicode digit in the hour
3771+ '2020-12-12T01:0٥:03' , # Unicode digit in the minute
3772+ '2020-12-12T01:02:0٥' , # Unicode digit in the second
3773+ '2020-12-12T01:02:03.٥' , # Unicode digit in the fraction
3774+ '2020-12-12T01:02:03.4_6' , # underscore in the fraction
3775+ '2020-12-12T01:02:03+0٥:00' , # Unicode digit in the tz hour
3776+ '2020-12-12T01:02:03+01:0٥' , # Unicode digit in the tz minute
3777+ '20201212T0102٣٤' , # Unicode digits in the basic-format time
3778+ '2009-04-19T12:30:45.+05:00' , # Empty fraction before offset
3779+ '2009-04-19T12:30:45.-05:00' , # Empty fraction before offset
3780+ '2009-04-19T12:30:45.Z' , # Empty fraction before Z
3781+ '2009-04-19T12:30:45,+05:00' , # Empty fraction (comma) before offset
37723782 ]
37733783
37743784 for bad_str in bad_strs :
@@ -4130,6 +4140,11 @@ def test_strftime_special(self):
41304140 self .assertEqual (t .strftime ('\0 ' * 1000 ), '\0 ' * 1000 )
41314141 self .assertEqual (t .strftime ('\0 %I%p%Z\0 %X' ), f'\0 { s1 } \0 { s2 } ' )
41324142 self .assertEqual (t .strftime ('%I%p%Z\0 %X\0 ' ), f'{ s1 } \0 { s2 } \0 ' )
4143+ # gh-152305: the year directives must not raise on a time.
4144+ for directive , expected in (('%Y' , '1900' ), ('%G' , '1900' ),
4145+ ('%C' , '19' ), ('%F' , '1900-01-01' )):
4146+ with self .subTest (directive = directive ):
4147+ self .assertEqual (t .strftime (directive ), expected )
41334148
41344149 def test_format (self ):
41354150 t = self .theclass (1 , 2 , 3 , 4 )
@@ -5040,6 +5055,10 @@ def test_fromisoformat_fails(self):
50405055 '24:01:00.000000' , # Has non-zero minutes on 24:00
50415056 '12:30:45+00:90:00' , # Time zone field out from range
50425057 '12:30:45+00:00:90' , # Time zone field out from range
5058+ '12:30:45.+05:00' , # Empty fraction before offset
5059+ '12:30:45.-05:00' , # Empty fraction before offset
5060+ '12:30:45.Z' , # Empty fraction before Z
5061+ '12:30:45,+05:00' , # Empty fraction (comma) before offset
50435062 ]
50445063
50455064 for bad_str in bad_strs :
0 commit comments