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.

classification
Title: XML File I/O Misbehavior with open() when the flag is 'r+'
Type: behavior Stage: resolved
Components: IO Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: r.david.murray, rexperience7, serhiy.storchaka
Priority: normal Keywords:

Created on 2014-03-20 04:52 by rexperience7, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg214174 - (view) Author: Rex Kim (rexperience7) Date: 2014-03-20 04:52
I found a misbehavior when reading and writing XML File by open() with 'r+' flag, some strings will be overlapped at the end of the file. 

you can demonstrate it like below:

f = open(file, "r+")
c = f.read()

# todo: write something to do

f.write(c)
f.close()

Actually I'm not sure if it's bug or not however it might be.
msg214216 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-03-20 12:53
Your example doesn't seem to have anything to do with XML, nor is it sufficient to reproduce the problem.  Can you provide a simple program including sample data that reproduces the behavior you are concerned with?  We'll also need to know what platform you are on.

Is it possible you are missing a line end character at the end of your file?
msg370466 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-05-31 14:33
Python 2.7 is no longer supported.
History
Date User Action Args
2022-04-11 14:58:00adminsetgithub: 65188
2020-05-31 14:33:53serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg370466

resolution: out of date
stage: resolved
2014-03-20 12:53:56r.david.murraysetnosy: + r.david.murray
messages: + msg214216
2014-03-20 04:52:18rexperience7create