diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-07-25 03:21:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-25 03:21:30 (GMT) |
commit | 0dd463c8a4269137ebed7cc29605c555030df94f (patch) | |
tree | 028ac900bebfc0c43a346f380dd7ed94851355c4 | |
parent | 0dd98c2d00a75efbec19c2ed942923981bc06683 (diff) | |
download | cpython-0dd463c8a4269137ebed7cc29605c555030df94f.zip cpython-0dd463c8a4269137ebed7cc29605c555030df94f.tar.gz cpython-0dd463c8a4269137ebed7cc29605c555030df94f.tar.bz2 |
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>
-rw-r--r-- | Lib/idlelib/iomenu.py | 11 | ||||
-rw-r--r-- | Misc/NEWS.d/next/IDLE/2020-07-24-17-49-58.bpo-41373.YQIPu_.rst | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Lib/idlelib/iomenu.py b/Lib/idlelib/iomenu.py index 74ebefd..8bb2fa6 100644 --- a/Lib/idlelib/iomenu.py +++ b/Lib/idlelib/iomenu.py @@ -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 index 0000000..b50a72fe --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2020-07-24-17-49-58.bpo-41373.YQIPu_.rst @@ -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. |