[ python-Bugs-1601501 ] utf_8_sig decode fails with buffer input

SourceForge.net noreply at sourceforge.net
Thu Nov 23 06:05:05 CET 2006


Bugs item #1601501, was opened at 2006-11-23 03:38
Message generated for change (Settings changed) made by doerwalter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1601501&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: bazwal (bazwal)
Assigned to: Nobody/Anonymous (nobody)
Summary: utf_8_sig decode fails with buffer input

Initial Comment:
when the decode function in encodings.utf_8_sig receives a buffer object, it fails because it tries to check for a bom using startswith:

>>> unicode('\xef\xbb\xbf', 'utf_8_sig')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.5/encodings/utf_8_sig.py", line 19, in decode
    if input.startswith(codecs.BOM_UTF8):
AttributeError: 'buffer' object has no attribute 'startswith'

the test should be changed to:

if input[:3] == codecs.BOM_UTF8:



----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2006-11-23 06:04

Message:
Logged In: YES 
user_id=89016
Originator: NO

Oops, I missed your stacktrace. Fixed in r52826.

(A better fix might be to add startswith() to buffer).

----------------------------------------------------------------------

Comment By: Walter Dörwald (doerwalter)
Date: 2006-11-23 05:00

Message:
Logged In: YES 
user_id=89016
Originator: NO

Can you provide a test that fails?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1601501&group_id=5470


More information about the Python-bugs-list mailing list