is unicode( codecs.BOM_UTF8, "utf8" ) necessary in Python 2.7/3?

Posted by Brian M. Hunt on Stack Overflow See other posts from Stack Overflow or by Brian M. Hunt
Published on 2011-11-11T15:20:52Z Indexed on 2011/11/11 17:52 UTC
Read the original article Hit count: 201

Filed under:
|
|
|

In a code review I came across the following code that contains the following:

# Python bug that renders the unicode identifier (0xEF 0xBB 0xBF)
# as a character.
# If untreated, it can prevent the page from validating or rendering 
# properly. 
bom = unicode( codecs.BOM_UTF8, "utf8" )
r = r.replace(bom, '')

This is in a function that passes a string to Response object (Django or Flask).

Is this still a bug that needs this fix in Python 2.7 or 3? Something tells me it isn't, but I thought I'd ask because I don't know this problem very well.

Thanks for reading.

© Stack Overflow or respective owner

Related posts about python

Related posts about unicode