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 Elena.Oat
Recipients Elena.Oat, da
Date 2018-04-27.13:53:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1524837231.94.0.682650639539.issue33361@psf.upfronthosting.co.za>
In-reply-to
Content
I've modified a little your example and it's clearly that the readline moves the cursor.

```
from __future__ import print_function

import codecs
import io


def run(stream):
    offset = stream.tell()
    try:
        stream.seek(0)
        header_row = stream.readline()
    finally:
        stream.seek(offset)
    print(offset)
    print(stream.tell())
    print('Got header: %r' % header_row)

    if stream.tell() == 0:
        print(stream.tell())
        print(stream.readline())
        print('Skipping the header: %r' % stream.readline())

    for index, line in enumerate(stream, start=2):
        print('Line %d: %r' % (index, line))


b = io.BytesIO(u'ab\r\ncd\ndef\n'.encode('utf-16-le'))
s = codecs.EncodedFile(b, 'utf-8', 'utf-16-le')
run(s)

```
The first call to readline returns cd instead of ab.
History
Date User Action Args
2018-04-27 13:53:51Elena.Oatsetrecipients: + Elena.Oat, da
2018-04-27 13:53:51Elena.Oatsetmessageid: <1524837231.94.0.682650639539.issue33361@psf.upfronthosting.co.za>
2018-04-27 13:53:51Elena.Oatlinkissue33361 messages
2018-04-27 13:53:51Elena.Oatcreate