removing BOM prepended by codecs?

Tim Golden mail at timgolden.me.uk
Tue Sep 24 09:33:10 EDT 2013


On 24/09/2013 14:01, J. Bagg wrote:
> I'm using:
> 
> outputfile = codecs.open (fn, 'w+', 'utf-8', errors='strict')

Well for the life of me I can't make that produce a BOM on 2.7 or 3.4.
In other words:

<code>
import codecs
with codecs.open("temp.txt", "w+", "utf-8", errors="strict") as f:
  f.write("abc")

with open("temp.txt", "rb") as f:
  assert f.read()[:3] == b"abc"

</code>

works without any assertion failures on 2.7 and 3.4, both running on
Win7 and on 2.7 and 3.3 running on Linux.

Have I misunderstood your situation?

TJG



More information about the Python-list mailing list