Nikolaus Rath added the comment:
Second question:
The following looks as if a BOM might be written for writeable, non-seekable
streams:
# don't write a BOM in the middle of a file
if self._seekable and self.writable():
position = self.buffer.tell()
if position != 0:
try:
self._get_encoder().setstate(0)
except LookupError:
# Sometimes the encoder doesn't exist
pass
Is that really desirable? It seems to me the safe choice is to *not* write the
BOM, except when we know it's safe. Eg:
# don't write a BOM unless we know we're at the beginning of a file
if (self.writeable() and not
(self._seekable and self.buffer.tell() == 0)):
try:
self._get_encoder().setstate(0)
except LookupError:
# Sometimes the encoder doesn't exist
pass
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15216>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com