@@ -1667,6 +1667,7 @@ def test_fromisoformat_fails(self):
1667
1667
# Test that fromisoformat() fails on invalid values
1668
1668
bad_strs = [
1669
1669
'' , # Empty string
1670
+ '\ud800 ' , # bpo-34454: Surrogate code point
1670
1671
'009-03-04' , # Not 10 characters
1671
1672
'123456789' , # Not a date
1672
1673
'200a-12-04' , # Invalid character in year
@@ -1675,6 +1676,7 @@ def test_fromisoformat_fails(self):
1675
1676
'2009-01-32' , # Invalid day
1676
1677
'2009-02-29' , # Invalid leap day
1677
1678
'20090228' , # Valid ISO8601 output not from isoformat()
1679
+ '2009\ud800 02\ud800 28' , # Separators are surrogate codepoints
1678
1680
]
1679
1681
1680
1682
for bad_str in bad_strs :
@@ -2587,7 +2589,8 @@ def test_fromisoformat_separators(self):
2587
2589
' ' , 'T' , '\u007f ' , # 1-bit widths
2588
2590
'\u0080 ' , 'ʁ' , # 2-bit widths
2589
2591
'ᛇ' , '時' , # 3-bit widths
2590
- '🐍' # 4-bit widths
2592
+ '🐍' , # 4-bit widths
2593
+ '\ud800 ' , # bpo-34454: Surrogate code point
2591
2594
]
2592
2595
2593
2596
for sep in separators :
@@ -2639,6 +2642,7 @@ def test_fromisoformat_fails_datetime(self):
2639
2642
# Test that fromisoformat() fails on invalid values
2640
2643
bad_strs = [
2641
2644
'' , # Empty string
2645
+ '\ud800 ' , # bpo-34454: Surrogate code point
2642
2646
'2009.04-19T03' , # Wrong first separator
2643
2647
'2009-04.19T03' , # Wrong second separator
2644
2648
'2009-04-19T0a' , # Invalid hours
@@ -2652,6 +2656,8 @@ def test_fromisoformat_fails_datetime(self):
2652
2656
'2009-04-19T03:15:45.123456+24:30' , # Invalid time zone offset
2653
2657
'2009-04-19T03:15:45.123456-24:30' , # Invalid negative offset
2654
2658
'2009-04-10ᛇᛇᛇᛇᛇ12:15' , # Too many unicode separators
2659
+ '2009-04\ud800 10T12:15' , # Surrogate char in date
2660
+ '2009-04-10T12\ud800 15' , # Surrogate char in time
2655
2661
'2009-04-19T1' , # Incomplete hours
2656
2662
'2009-04-19T12:3' , # Incomplete minutes
2657
2663
'2009-04-19T12:30:4' , # Incomplete seconds
@@ -3521,6 +3527,7 @@ def test_fromisoformat_timespecs(self):
3521
3527
def test_fromisoformat_fails (self ):
3522
3528
bad_strs = [
3523
3529
'' , # Empty string
3530
+ '12\ud800 00' , # Invalid separator - surrogate char
3524
3531
'12:' , # Ends on a separator
3525
3532
'12:30:' , # Ends on a separator
3526
3533
'12:30:15.' , # Ends on a separator
0 commit comments