From 97fcdd3917e403b147fe8cb81f719c627041ad75 Mon Sep 17 00:00:00 2001 From: Emmanuel Arias Date: Thu, 23 Jul 2020 23:27:39 -0300 Subject: [PATCH] Fix eol_convention when file does not exist When a new file is loaded, the current loadfile read for the newline to set the eol_convention. As does not exist for a empty file a None is saved and for that reason the exception is raised --- Lib/idlelib/iomenu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/idlelib/iomenu.py b/Lib/idlelib/iomenu.py index 74ebefd420..d64a9def19 100644 --- a/Lib/idlelib/iomenu.py +++ b/Lib/idlelib/iomenu.py @@ -129,7 +129,7 @@ class IOBinding: with tokenize.open(filename) as f: chars = f.read() fileencoding = f.encoding - eol_convention = f.newlines + eol_convention = f.newlines if f.newlines else os.linesep converted = False except (UnicodeDecodeError, SyntaxError): # Wait for the editor window to appear @@ -144,7 +144,7 @@ class IOBinding: with open(filename, encoding=enc) as f: chars = f.read() fileencoding = f.encoding - eol_convention = f.newlines + eol_convention = f.newlines if f.newlines else os.linesep converted = True except OSError as err: tkMessageBox.showerror("I/O Error", str(err), parent=self.text) -- 2.27.0