homepage

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 Manuel Ignacio Pérez Alcolea
Recipients Manuel Ignacio Pérez Alcolea
Date 2019年11月06日.04:04:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1573013055.2.0.421780617853.issue38710@roundup.psfhosted.org>
In-reply-to
Content
There seems to be a bug in the `io.TextIOWrapper` class while working in 'r+' mode, although I can't say the source of the problem is right there.
The write pointer doesn't match `file.tell()` after performing a read operation.
For example, this file, consisting of 3 lines:
 line one
 line two
 line three
Doesn't result in the expected modification running the following program:
with open('file', 'r+', buffering=1) as f:
 print(f.tell()) # => 0
 print(f.readline().strip()) # we read 1 line
 print(f.tell()) # => 9 
 print('Hello', file=f) # we write "Hello\n"
 print(f.tell()) # => 34
Instad of
 line one
 Hello
 wo
 line three
It results in
 line one
 line two
 line threeHello
But it works just fine if `f.seek(f.tell())` is added the program, right before the write operation.
There are several possible explanations on StackOverflow, involving the buffering for IO in text files:
https://stackoverflow.com/a/58722058/11601118 
History
Date User Action Args
2019年11月06日 04:04:15Manuel Ignacio Pérez Alcoleasetrecipients: + Manuel Ignacio Pérez Alcolea
2019年11月06日 04:04:15Manuel Ignacio Pérez Alcoleasetmessageid: <1573013055.2.0.421780617853.issue38710@roundup.psfhosted.org>
2019年11月06日 04:04:15Manuel Ignacio Pérez Alcolealinkissue38710 messages
2019年11月06日 04:04:14Manuel Ignacio Pérez Alcoleacreate

AltStyle によって変換されたページ (->オリジナル) /