[New-bugs-announce] [issue12843] file object read* methods in append mode overflows

Otacon Karurosu report at bugs.python.org
Fri Aug 26 01:09:03 CEST 2011


New submission from Otacon Karurosu <otacon.karurosu at gmail.com>:

When opening a file in append mode and attempting to read after doing a write operation causes the read method to overflow and read memory directly (instead of returning an empty string)

The following code prints garbage:

f2 = open("test", "w+b")
f2.write("python!")
print f2.readline()

However the following print empty lines:

f2 = open("test", "w+b")
print f2.readline()

f2 = open("test", "w+b")
f2.write("python!")
f2.seek(f2.tell())
print f2.readline()

This also happens with tempfiles:

f = tempfile.TemporaryFile()
f.write("python!")
print f.readline()

----------
components: Interpreter Core, Library (Lib)
messages: 142994
nosy: Otacon.Karurosu
priority: normal
severity: normal
status: open
title: file object read* methods in append mode overflows
type: behavior
versions: Python 2.6, Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12843>
_______________________________________


More information about the New-bugs-announce mailing list