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 <tjreedy@udel.edu>
This commit is contained in:
Serhiy Storchaka 2020-07-25 06:21:30 +03:00 committed by GitHub
parent 0dd98c2d00
commit 0dd463c8a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -155,6 +155,17 @@ class IOBinding:
parent=self.text) parent=self.text)
return False 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.text.delete("1.0", "end")
self.set_filename(None) self.set_filename(None)
self.fileencoding = fileencoding self.fileencoding = fileencoding

View File

@ -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.