Message142994
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() |
|
Date |
User |
Action |
Args |
2011-08-25 23:09:03 | Otacon.Karurosu | set | recipients:
+ Otacon.Karurosu |
2011-08-25 23:09:03 | Otacon.Karurosu | set | messageid: <1314313743.28.0.803214021161.issue12843@psf.upfronthosting.co.za> |
2011-08-25 23:09:02 | Otacon.Karurosu | link | issue12843 messages |
2011-08-25 23:09:02 | Otacon.Karurosu | create | |
|