Message11908
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. |
|
Date |
User |
Action |
Args |
2018-04-15 17:03:13 | jeff.allen | set | messageid: <1523811793.03.0.682650639539.issue2363@psf.upfronthosting.co.za> |
2018-04-15 17:03:13 | jeff.allen | set | recipients:
+ jeff.allen, fwierzbicki, zyasoft, santa4nt, amit, psykiatris |
2018-04-15 17:03:13 | jeff.allen | link | issue2363 messages |
2018-04-15 17:03:12 | jeff.allen | create | |
|