]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add a test for UTF-16 reading where the byte sequence doesn't start with
authorWalter Dörwald <walter@livinglogic.de>
Fri, 4 Feb 2005 14:15:34 +0000 (14:15 +0000)
committerWalter Dörwald <walter@livinglogic.de>
Fri, 4 Feb 2005 14:15:34 +0000 (14:15 +0000)
a BOM.

Lib/test/test_codecs.py

index dbe9b88dbd8aa75bc92fc63517a0ddb681633a96..5abc78565740257d46f0e8ee301631006c403b3d 100644 (file)
@@ -159,6 +159,15 @@ class UTF16Test(ReadTest):
         f = reader(s)
         self.assertEquals(f.read(), u"spamspam")
 
+    def test_badbom(self):
+        s = StringIO.StringIO("\xff\xff")
+        f = codecs.getwriter(self.encoding)(s)
+        self.assertRaises(UnicodeError, f.read)
+
+        s = StringIO.StringIO("\xff\xff\xff\xff")
+        f = codecs.getwriter(self.encoding)(s)
+        self.assertRaises(UnicodeError, f.read)
+
     def test_partial(self):
         self.check_partial(
             u"\x00\xff\u0100\uffff",