Message11908

Author jeff.allen
Recipients amit, fwierzbicki, jeff.allen, psykiatris, santa4nt, zyasoft
Date 2018-04-15.17:03:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1523811793.03.0.682650639539.issue2363@psf.upfronthosting.co.za>
In-reply-to
Content
You're right, SeekTellTest in test_fileio is a good place to start. seek() calls I found in test_file are incidental.

It sounds like you're homing in of some invalid behaviour where tell() is maybe returning only partial counts.

To answer an earlier question, yes, readline() consumes the end of line, if there is one, and appends it to the returned bytes. I put it that way carefully, because an end of line is not necessarily an end-of-line *character*. Trying this in CPython 2.7.14:

>>> binary = open('macbeth.txt', 'rb')
>>> while "wood" not in binary.readline(): p = binary.tell()
...
>>> p
55502L
>>> binary.seek(p)
>>> binary.readline()
'    Makes wing to the rooky wood:\r\n'


>>> text = open('macbeth.txt', 'r')
>>> while "wood" not in text.readline(): p = text.tell()
...
>>> p
55502L
>>> text.seek(p)
>>> text.readline()
'    Makes wing to the rooky wood:\n'


However, tell and seek are working in terms of the byte position at which the line was found, not a "character" offset in a stream where line endings have been converted.
History
Date User Action Args
2018-04-15 17:03:13jeff.allensetmessageid: <1523811793.03.0.682650639539.issue2363@psf.upfronthosting.co.za>
2018-04-15 17:03:13jeff.allensetrecipients: + jeff.allen, fwierzbicki, zyasoft, santa4nt, amit, psykiatris
2018-04-15 17:03:13jeff.allenlinkissue2363 messages
2018-04-15 17:03:12jeff.allencreate