]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41373: IDLE: Fix saving files loaded with no newlines or mixed newlines (GH-21597)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 25 Jul 2020 03:38:46 +0000 (20:38 -0700)
committerGitHub <noreply@github.com>
Sat, 25 Jul 2020 03:38:46 +0000 (20:38 -0700)
Fixes regression in 3.8.4 and 3.9.0b4.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 0dd463c8a4269137ebed7cc29605c555030df94f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/idlelib/iomenu.py
Misc/NEWS.d/next/IDLE/2020-07-24-17-49-58.bpo-41373.YQIPu_.rst [new file with mode: 0644]

index 74ebefd4208f78fac6eede4f1aa25159566a1ef1..8bb2fa6a6e79393ce9b82ab0a556c5268da852ac 100644 (file)
@@ -155,6 +155,17 @@ class IOBinding:
                                    parent=self.text)
             return False
 
+        if not isinstance(eol_convention, str):
+            # If the file does not contain line separators, it is None.
+            # If the file contains mixed line separators, it is a tuple.
+            if eol_convention is not None:
+                tkMessageBox.showwarning("Mixed Newlines",
+                                         "Mixed newlines detected.\n"
+                                         "The file will be changed on save.",
+                                         parent=self.text)
+                converted = True
+            eol_convention = os.linesep  # default
+
         self.text.delete("1.0", "end")
         self.set_filename(None)
         self.fileencoding = fileencoding
diff --git a/Misc/NEWS.d/next/IDLE/2020-07-24-17-49-58.bpo-41373.YQIPu_.rst b/Misc/NEWS.d/next/IDLE/2020-07-24-17-49-58.bpo-41373.YQIPu_.rst
new file mode 100644 (file)
index 0000000..b50a72f
--- /dev/null
@@ -0,0 +1,3 @@
+Save files loaded with no line ending, as when blank, or different line
+endings, by setting its line ending to the system default. Fix regression in
+3.8.4 and 3.9.0b4.