From 353f8d2282b1a48376f8813fd1170445a0cda873 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 13 May 2019 18:29:15 -0400 Subject: [PATCH] [2.7] bpo-36807: When saving a file in IDLE, call flush and fsync (GH-13102) (GH-13293) --- Lib/idlelib/IOBinding.py | 2 ++ Misc/NEWS.d/next/IDLE/2019-05-05-16-27-53.bpo-13102.AGNWYJ.rst | 1 + 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/IDLE/2019-05-05-16-27-53.bpo-13102.AGNWYJ.rst diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py index 2aba46e0df4..872bece4767 100644 --- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/IOBinding.py @@ -383,6 +383,8 @@ class IOBinding: 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 00000000000..2a905bf0eec --- /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.