[ python-Bugs-1156259 ] [2.4 regression] seeking in codecs.reader
broken
SourceForge.net
noreply at sourceforge.net
Fri Mar 4 10:56:02 CET 2005
Bugs item #1156259, was opened at 2005-03-03 23:29
Message generated for change (Comment added) made by lemburg
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1156259&group_id=5470
Category: Extension Modules
Group: Python 2.4
Status: Open
Resolution: None
Priority: 7
Submitted By: Matthias Klose (doko)
Assigned to: Martin v. Löwis (loewis)
Summary: [2.4 regression] seeking in codecs.reader broken
Initial Comment:
[forwarded from
https://bugzilla.ubuntu.com/show_bug.cgi?id=6972 ]
This is a regression; the following script (call as
"scriptname some_textfile")
fails.
It is obvious that the file starts with a number of
random bytes from the
previous run.
Uncommenting the two #XXX lines makes the bug go away.
So does running it with
Python 2.3.5
import sys
import codecs
from random import random
data = codecs.getreader("utf-8")(open(sys.argv[1]))
df = data.read()
for t in range(30):
#XXX data.seek(0,1)
#XXX data.read()
data.seek(0,0)
dn=""
for l in data:
dn += l
if random() < 0.1: break
if not df.startswith(dn):
print "OUCH",t
print "BAD:", dn[0:100]
print "GOOD:", df[0:100]
sys.exit(1)
print "OK",len(df)
sys.exit(0)
----------------------------------------------------------------------
>Comment By: M.-A. Lemburg (lemburg)
Date: 2005-03-04 10:56
Message:
Logged In: YES
user_id=38388
This is obviously related to the buffer logic that Walter added
to support .readline().
In order to fix the problem, a .seek() method must be
implemented
that resets the buffers whenever called (before asking the
stream
to seek to the specified stream position).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1156259&group_id=5470
More information about the Python-bugs-list
mailing list