mirror of
https://github.com/python/cpython.git
synced 2025-08-19 16:20:59 +00:00
Backport r54786:
Fix utf-8-sig incremental decoder, which didn't recognise a BOM when the first chunk fed to the decoder started with a BOM, but was longer than 3 bytes.
This commit is contained in:
parent
552ba11085
commit
93a3603c67
3 changed files with 19 additions and 7 deletions
|
@ -430,6 +430,11 @@ class UTF8SigTest(ReadTest):
|
|||
# SF bug #1601501: check that the codec works with a buffer
|
||||
unicode("\xef\xbb\xbf", "utf-8-sig")
|
||||
|
||||
def test_bom(self):
|
||||
d = codecs.getincrementaldecoder("utf-8-sig")()
|
||||
s = u"spam"
|
||||
self.assertEqual(d.decode(s.encode("utf-8-sig")), s)
|
||||
|
||||
class EscapeDecodeTest(unittest.TestCase):
|
||||
def test_empty(self):
|
||||
self.assertEquals(codecs.escape_decode(""), ("", 0))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue