Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54697

Re: removing BOM prepended by codecs?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; '2.7': 0.14; "'utf-8',": 0.16; 'codecs': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'tjg': 0.16; 'win7': 0.16; 'wrote:': 0.18; 'import': 0.22; 'header:User-Agent:1': 0.23; 'received:192.168.100': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply- To:1': 0.27; "i'm": 0.30; 'assert': 0.31; 'linux.': 0.31; 'running': 0.33; "can't": 0.35; 'subject:?': 0.36; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'failures': 0.60; 'life': 0.66; 'from:addr:mail': 0.83
Date Tue, 24 Sep 2013 14:33:10 +0100
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4
MIME-Version 1.0
To python-list@python.org
Subject Re: removing BOM prepended by codecs?
References <52418D10.9080508@kent.ac.uk>
In-Reply-To <52418D10.9080508@kent.ac.uk>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
Cc j.bagg@kent.ac.uk
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.295.1380029594.18130.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1380029594 news.xs4all.nl 15975 [2001:888:2000:d::a6]:44441
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:54697

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: removing BOM prepended by codecs? Tim Golden <mail@timgolden.me.uk> - 2013-09-24 14:33 +0100

csiph-web