homepage

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 vstinner
Recipients vstinner
Date 2011年07月07日.13:12:46
SpamBayes Score 0.000988855
Marked as misclassified No
Message-id <1310044367.3.0.915426685652.issue12513@psf.upfronthosting.co.za>
In-reply-to
Content
The following test fails with an AssertionError('a' != 'b') on the first read.
import codecs
FILENAME = 'test'
with open(FILENAME, 'wb') as f:
 f.write('abcd'.encode('utf-8'))
with codecs.open(FILENAME, 'r+', encoding='utf-8') as f:
 f.write("1")
 pos = f.writer.tell()
 assert pos == 1, "writer pos: %s != 1" % pos
 pos = f.reader.tell()
 assert pos == 1, "reader pos: %s != 1" % pos
 pos = f.stream.tell()
 assert pos == 1, "stream pos: %s != 1" % pos
 # read() must call writer.flush()
 char = f.read(1)
 assert char == 'b', "%r != 'b'" % (char,)
 # write() must rewind the raw stream
 f.write('3')
 tail = f.read()
 assert tail == 'd', "%r != 'd'" % (tail,)
 f.flush()
 with open(FILENAME, 'rb') as f:
 assert f.read() == b'1b3d'
I suppose that readline(), readlines() and __next__() have also issues.
See also issue #12215: similar issue with io.TextIOWrapper.
History
Date User Action Args
2011年07月07日 13:12:47vstinnersetrecipients: + vstinner
2011年07月07日 13:12:47vstinnersetmessageid: <1310044367.3.0.915426685652.issue12513@psf.upfronthosting.co.za>
2011年07月07日 13:12:46vstinnerlinkissue12513 messages
2011年07月07日 13:12:46vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /