[Python-checkins] [2.7] bpo-36807: When saving a file in IDLE, call flush and fsync (GH-13102) (GH-13293)

Terry Jan Reedy webhook-mailer at python.org
Mon May 13 18:29:19 EDT 2019


https://github.com/python/cpython/commit/353f8d2282b1a48376f8813fd1170445a0cda873
commit: 353f8d2282b1a48376f8813fd1170445a0cda873
branch: 2.7
author: Terry Jan Reedy <tjreedy at udel.edu>
committer: GitHub <noreply at github.com>
date: 2019-05-13T18:29:15-04:00
summary:

[2.7] bpo-36807: When saving a file in IDLE, call flush and fsync (GH-13102) (GH-13293)

files:
A Misc/NEWS.d/next/IDLE/2019-05-05-16-27-53.bpo-13102.AGNWYJ.rst
M Lib/idlelib/IOBinding.py

diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
index 2aba46e0df46..872bece47674 100644
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -383,6 +383,8 @@ def writefile(self, filename):
         try:
             with open(filename, "wb") as f:
                 f.write(chars)
+                f.flush()
+                os.fsync(f.fileno())
             return True
         except IOError as msg:
             tkMessageBox.showerror("I/O Error", str(msg),
diff --git a/Misc/NEWS.d/next/IDLE/2019-05-05-16-27-53.bpo-13102.AGNWYJ.rst b/Misc/NEWS.d/next/IDLE/2019-05-05-16-27-53.bpo-13102.AGNWYJ.rst
new file mode 100644
index 000000000000..2a905bf0eecf
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2019-05-05-16-27-53.bpo-13102.AGNWYJ.rst
@@ -0,0 +1 @@
+When saving a file, call os.fsync() so bits are flushed to e.g. USB drive.



More information about the Python-checkins mailing list