You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TextIO and BufferedIO (which are gotten via commonly used open('README.rst'), open('README.rst', 'rb')) retry partial writes providing a user a guarantee either all bytes will be written or an exception will be thrown.
FileIO is "Raw I/O" and by PEP-3116 design, as documented, and currently implemented does not retry partial writes.
I would like to try and change the behavior of buffering=0 to use BufferedIO but with a 0 sized buffer, and that is on my roadmap but will be a while (people use the flag for a reason / get benefit!). This will mean open() always returns an object which implements "Write all or throw exception" behavior.
Add warning / document existing behavior on open() in the meantime.
Uh oh!
There was an error while loading. Please reload this page.
Documentation
Discuss thread: https://discuss.python.org/t/change-open-write-to-guarantee-all-bytes-will-be-written-or-an-exception-will-be-thrown/71082
read
andreadall
. Update the code comments to match current behavior.readall()
makes multiple system calls by designopen()
builtin thatbuffering=0
, which currently just says "disables buffering") changes how.write()
behaves and may result in data loss as a result of a partial write (ex. Corrupt .pyc files stay on disk after failed writes #126606).TextIO
andBufferedIO
(which are gotten via commonly usedopen('README.rst')
,open('README.rst', 'rb')
) retry partial writes providing a user a guarantee either all bytes will be written or an exception will be thrown.FileIO
is "Raw I/O" and by PEP-3116 design, as documented, and currently implemented does not retry partial writes.buffering=0
currently speeds up writing a file, but it can also result in corrupted files, ex. Corrupt .pyc files stay on disk after failed writes #126606 from using FileIO directlybuffering=0
to use BufferedIO but with a 0 sized buffer, and that is on my roadmap but will be a while (people use the flag for a reason / get benefit!). This will meanopen()
always returns an object which implements "Write all or throw exception" behavior.open()
in the meantime.Linked PRs
The text was updated successfully, but these errors were encountered: