@@ -1281,6 +1281,13 @@ def test_strptime_whitespace(self):
12811281 fmt = format_space .join (('%Y' , '%m' , '%d' ))
12821282 self .assertEqual (date .strptime (text , fmt ), date (2024 , 2 , 29 ))
12831283
1284+ def test_strptime_whitespace_before_adjacent_fields (self ):
1285+ for separator in ('\x1c ' , '\x1d ' , '\x1e ' , '\x1f ' ):
1286+ with self .subTest (separator = separator ):
1287+ text = f'2024{ separator } 112'
1288+ fmt = f'%Y{ separator } %d%m'
1289+ self .assertEqual (date .strptime (text , fmt ), date (2024 , 2 , 11 ))
1290+
12841291 def test_strptime_single_digit (self ):
12851292 # bpo-34903: Check that single digit dates are allowed.
12861293 strptime = date .strptime
@@ -3202,6 +3209,14 @@ def test_strptime_whitespace(self):
32023209 self .assertEqual (self .theclass .strptime (text , fmt ),
32033210 self .theclass (2024 , 2 , 29 , 12 , 34 , 56 ))
32043211
3212+ def test_strptime_whitespace_before_adjacent_fields (self ):
3213+ for separator in ('\x1c ' , '\x1d ' , '\x1e ' , '\x1f ' ):
3214+ with self .subTest (separator = separator ):
3215+ text = f'2024{ separator } 112 34{ separator } 123'
3216+ fmt = f'%Y{ separator } %d%m %M{ separator } %H%S'
3217+ self .assertEqual (self .theclass .strptime (text , fmt ),
3218+ self .theclass (2024 , 2 , 11 , 12 , 34 , 3 ))
3219+
32053220 def test_strptime_numeric_fallback (self ):
32063221 cases = (
32073222 ('2024\0 -02-29' , '%Y\0 -%m-%d' , (2024 , 2 , 29 )),
@@ -4435,6 +4450,14 @@ def test_strptime_whitespace(self):
44354450 self .assertEqual (self .theclass .strptime (text , fmt ),
44364451 self .theclass (12 , 34 , 56 ))
44374452
4453+ def test_strptime_whitespace_before_adjacent_fields (self ):
4454+ for separator in ('\x1c ' , '\x1d ' , '\x1e ' , '\x1f ' ):
4455+ with self .subTest (separator = separator ):
4456+ text = f'34{ separator } 123'
4457+ fmt = f'%M{ separator } %H%S'
4458+ self .assertEqual (self .theclass .strptime (text , fmt ),
4459+ self .theclass (12 , 34 , 3 ))
4460+
44384461 def test_strptime_tz (self ):
44394462 strptime = self .theclass .strptime
44404463 self .assertEqual (strptime ("+0002" , "%z" ).utcoffset (), 2 * MINUTE )
0 commit comments