[issue30460] file opened for updating cannot write after read

2021-02-25 Thread Eryk Sun
Change by Eryk Sun : -- resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue30460] file opened for updating cannot write after read

2017-05-25 Thread Jeremy Kloth
Jeremy Kloth added the comment: It seems to me that it is a quite simple fix: --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -1110,7 +1110,7 @@ file_read(PyFileObject *f, PyObject *args) -clearerr(f->f_fp); +if (ferror(f->f_fp)) clearerr(f->f_fp); which is

[issue30460] file opened for updating cannot write after read

2017-05-24 Thread Eryk Sun
Eryk Sun added the comment: It might be simplest to close this as 3rd party since it's similar to bpo-29817. A workaround is to call f.seek(0, 1) to reset the stream state when switching between reading and writing. That said, a switch to writing at EOF should be supported. The problem is

[issue30460] file opened for updating cannot write after read

2017-05-24 Thread Jeremy Kloth
New submission from Jeremy Kloth: Attempting to append to an existing file fails with no error set: >>> import os, tempfile >>> fd, fn = tempfile.mkstemp() >>> os.write(fd, 'some text') 9 >>> os.close(fd) >>> with open(fn, 'r+') as f: ... f.read() ... f.write('more text') ... 'some