@@ -1793,9 +1793,6 @@ def test_issue8271(self):
17931793 self .assertEqual (seq .decode ('utf-8' , 'ignore' ),
17941794 res .replace ('\uFFFD ' , '' ))
17951795
1796- def to_bytestring (self , seq ):
1797- return bytes (int (c , 16 ) for c in seq .split ())
1798-
17991796 def assertCorrectUTF8Decoding (self , seq , res , err ):
18001797 """
18011798 Check that an invalid UTF-8 sequence raises a UnicodeDecodeError when
@@ -1851,7 +1848,7 @@ def test_unexpected_end_of_data(self):
18511848 ]
18521849 FFFD = '\ufffd '
18531850 for seq in sequences :
1854- self .assertCorrectUTF8Decoding (self . to_bytestring (seq ), '\ufffd ' ,
1851+ self .assertCorrectUTF8Decoding (bytes . fromhex (seq ), '\ufffd ' ,
18551852 'unexpected end of data' )
18561853
18571854 def test_invalid_cb_for_2bytes_seq (self ):
@@ -1873,7 +1870,7 @@ def test_invalid_cb_for_2bytes_seq(self):
18731870 ('DF C0' , FFFDx2 ), ('DF FF' , FFFDx2 ),
18741871 ]
18751872 for seq , res in sequences :
1876- self .assertCorrectUTF8Decoding (self . to_bytestring (seq ), res ,
1873+ self .assertCorrectUTF8Decoding (bytes . fromhex (seq ), res ,
18771874 'invalid continuation byte' )
18781875
18791876 def test_invalid_cb_for_3bytes_seq (self ):
@@ -1931,7 +1928,7 @@ def test_invalid_cb_for_3bytes_seq(self):
19311928 ('EF BF C0' , FFFDx2 ), ('EF BF FF' , FFFDx2 ),
19321929 ]
19331930 for seq , res in sequences :
1934- self .assertCorrectUTF8Decoding (self . to_bytestring (seq ), res ,
1931+ self .assertCorrectUTF8Decoding (bytes . fromhex (seq ), res ,
19351932 'invalid continuation byte' )
19361933
19371934 def test_invalid_cb_for_4bytes_seq (self ):
@@ -2010,7 +2007,7 @@ def test_invalid_cb_for_4bytes_seq(self):
20102007 ('F4 8F BF C0' , FFFDx2 ), ('F4 8F BF FF' , FFFDx2 )
20112008 ]
20122009 for seq , res in sequences :
2013- self .assertCorrectUTF8Decoding (self . to_bytestring (seq ), res ,
2010+ self .assertCorrectUTF8Decoding (bytes . fromhex (seq ), res ,
20142011 'invalid continuation byte' )
20152012
20162013 def test_codecs_idna (self ):
0 commit comments