This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc
Date 2009-01-07.00:21:15
SpamBayes Score 0.002590916
Marked as misclassified No
Message-id <>
First write a utf-16 file with its signature:

>>> f1 = open('utf16.txt', 'w', encoding='utf-16')
>>> f1.write('0123456789')
>>> f1.close()

Then read it twice:

>>> f2 = open('utf16.txt', 'r', encoding='utf-16')
>>> print('read1', ascii(
read1 '0123456789'
>>> print('read2', ascii(
read2 '\ufeff0123456789'

The second read returns the BOM!
This is because the zero in seek(0) is a "cookie" which contains both the position 
and the decoder state. Unfortunately, state=0 means 'endianness has been determined: 
native order'.

maybe a suggestion: handle seek(0) as a special value which calls decoder.reset().
The patch implement this idea.
Date User Action Args
2009-01-07 00:21:17amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc
2009-01-07 00:21:17amaury.forgeotdarcsetmessageid: <>
2009-01-07 00:21:16amaury.forgeotdarclinkissue4862 messages
2009-01-07 00:21:16amaury.forgeotdarccreate