Skip to content

Commit 0dd463c

Browse files
bpo-41373: IDLE: Fix saving files loaded with no newlines or mixed newlines (GH-21597)
Fixes regression in 3.8.4 and 3.9.0b4. Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent 0dd98c2 commit 0dd463c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Lib/idlelib/iomenu.py

+11
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,17 @@ def loadfile(self, filename):
155155
parent=self.text)
156156
return False
157157

158+
if not isinstance(eol_convention, str):
159+
# If the file does not contain line separators, it is None.
160+
# If the file contains mixed line separators, it is a tuple.
161+
if eol_convention is not None:
162+
tkMessageBox.showwarning("Mixed Newlines",
163+
"Mixed newlines detected.\n"
164+
"The file will be changed on save.",
165+
parent=self.text)
166+
converted = True
167+
eol_convention = os.linesep # default
168+
158169
self.text.delete("1.0", "end")
159170
self.set_filename(None)
160171
self.fileencoding = fileencoding
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Save files loaded with no line ending, as when blank, or different line
2+
endings, by setting its line ending to the system default. Fix regression in
3+
3.8.4 and 3.9.0b4.

0 commit comments

Comments
 (0)