[issue45076] open "r+" problem

2021-09-01 Thread otn


otn  added the comment:

It works correct for ver2.6, and also "rb+".
Buffering procsess should work the same as those case.

--

___
Python tracker 
<https://bugs.python.org/issue45076>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45076] open "r+" problem

2021-09-01 Thread otn


New submission from otn :

For opened file as "r+", even if write() then readline(), readline() is 
executed first.

When add tell() after write(), it works correctly.

==
data1 = "aa\nbb\ncc\n"
data2 = "xx\n"

with open("data.txt","w") as f:
f.write(data1)

with open("data.txt","r+") as f:
f.write(data2)
#   f.tell()
print("Line:",repr(f.readline()))

with open("data.txt") as f:
print("All:",repr(f.read()))
==
OUTPUT:
Line: 'aa\n'
All: 'aa\nbb\ncc\nxx\n'

EXPECTED:
Line: 'bb\n'
All: 'xx\nbb\ncc\n'

--
components: IO
messages: 400826
nosy: otn
priority: normal
severity: normal
status: open
title: open "r+" problem
type: behavior
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue45076>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com