Windows EOL sequence not converted correctly, encoding error.
Caused file save to fail. Bug 1130.
M idlelib/IOBinding.py
M idlelib/NEWS.txt
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
index cde2dae..5a15995 100644
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -242,7 +242,6 @@
eol = r"(\r\n)|\n|\r" # \r\n (Windows), \n (UNIX), or \r (Mac)
eol_re = re.compile(eol)
- eol_convention = os.linesep # Default
def loadfile(self, filename):
try:
@@ -389,9 +388,10 @@
def writefile(self, filename):
self.fixlastline()
- chars = self.encode(self.text.get("1.0", "end-1c"))
+ text = self.text.get("1.0", "end-1c")
if self.eol_convention != "\n":
- chars = chars.replace("\n", self.eol_convention)
+ text = text.replace("\n", self.eol_convention)
+ chars = self.encode(self.text.get("1.0", "end-1c"))
try:
f = open(filename, "wb")
f.write(chars)