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

Terry Jan Reedy webhook-mailer at python.org
Mon May 13 08:31:34 EDT 2019


https://github.com/python/cpython/commit/4f098b35f58e911639f8e9adc393d5cf5c792e7f
commit: 4f098b35f58e911639f8e9adc393d5cf5c792e7f
branch: master
author: Guido van Rossum <guido at python.org>
committer: Terry Jan Reedy <tjreedy at udel.edu>
date: 2019-05-13T08:31:29-04:00
summary:

bpo-36807: When saving a file in IDLE, call flush and fsync (#13102)

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

diff --git a/Lib/idlelib/iomenu.py b/Lib/idlelib/iomenu.py
index f5bced597aa8..b9e813be0630 100644
--- a/Lib/idlelib/iomenu.py
+++ b/Lib/idlelib/iomenu.py
@@ -384,6 +384,8 @@ def writefile(self, filename):
         try:
             with open(filename, "wb") as f:
                 f.write(chars)
+                f.flush()
+                os.fsync(f.fileno())
             return True
         except OSError 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..18b31b1fe505
--- /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.flush() so bits are flushed to e.g. USB drive.



More information about the Python-checkins mailing list