r52827 - in python/branches/release25-maint/Lib: encodings/utf_8_sig.py test/test_codecs.py

Author: walter.doerwald Date: Thu Nov 23 06:06:31 2006 New Revision: 52827 Modified: python/branches/release25-maint/Lib/encodings/utf_8_sig.py python/branches/release25-maint/Lib/test/test_codecs.py Log: Backport checkin: Change decode() so that it works with a buffer (i.e. unicode(..., 'utf-8-sig')) SF bug #1601501. Modified: python/branches/release25-maint/Lib/encodings/utf_8_sig.py ============================================================================== --- python/branches/release25-maint/Lib/encodings/utf_8_sig.py (original) +++ python/branches/release25-maint/Lib/encodings/utf_8_sig.py Thu Nov 23 06:06:31 2006 @@ -16,7 +16,7 @@ def decode(input, errors='strict'): prefix = 0 - if input.startswith(codecs.BOM_UTF8): + if input[:3] == codecs.BOM_UTF8: input = input[3:] prefix = 3 (output, consumed) = codecs.utf_8_decode(input, errors, True) Modified: python/branches/release25-maint/Lib/test/test_codecs.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_codecs.py (original) +++ python/branches/release25-maint/Lib/test/test_codecs.py Thu Nov 23 06:06:31 2006 @@ -426,6 +426,10 @@ ] ) + def test_bug1601501(self): + # SF bug #1601501: check that the codec works with a buffer + unicode("\xef\xbb\xbf", "utf-8-sig") + class EscapeDecodeTest(unittest.TestCase): def test_empty(self): self.assertEquals(codecs.escape_decode(""), ("", 0))
participants (1)
-
walter.doerwald