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 jan
Recipients jan, paul.moore, steve.dower, tim.golden, zach.ware
Date 2017-03-15.09:47:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489571250.73.0.412338383823.issue29817@psf.upfronthosting.co.za>
In-reply-to
Content
In Python 2.7.12 when reading, writing and subsequently reading again from a file, python seems to write garbage.

For example when running this in python IDLE: 

import os 
testPath = r"myTestFile.txt"

## Make sure the file exists and its empty
with open(testPath,"w") as tFile:
    tFile.write("")

print "Our Test File: ", os.path.abspath(testPath )

with open(testPath, "r+") as tFile:
    ## First we read the file 
    data = tFile.read()

    ## Now we write some data 
    tFile.write('Some Data')

    ## Now we read the file again
    tFile.read()


When now looking at the file the data is the following:

Some Data @ sb d Z d d l m Z d d d ・ ・ YZ e d k r^ d d l m Z e d d d d e ・n d S( s9
Implement Idle Shell history mechanism with History
...<omitted the rest of the data> 

As mentioned in the comments on stack overflow ( see link ) this might be a buffer overrun but I am not sure. Also I guess this could be used as a security vulnerability... 

http://stackoverflow.com/questions/40373457/python-r-read-write-read-writes-garbage-to-a-file?noredirect=1#comment72580538_40373457
History
Date User Action Args
2017-03-15 09:47:30jansetrecipients: + jan, paul.moore, tim.golden, zach.ware, steve.dower
2017-03-15 09:47:30jansetmessageid: <1489571250.73.0.412338383823.issue29817@psf.upfronthosting.co.za>
2017-03-15 09:47:30janlinkissue29817 messages
2017-03-15 09:47:30jancreate