1. Matt McClure
  2. cpython


Kurt B. Kaiser  committed c947a04

1. Fix File Open: don't encode filename to UTF-8 bytes
2. Get test() code working.

  • Participants
  • Parent commits e7696fc
  • Branches default

Comments (0)

Files changed (1)

File Lib/idlelib/IOBinding.py

View file
  • Ignore whitespace
 import tkMessageBox
 import re
 from Tkinter import *
-from .SimpleDialog import SimpleDialog
+from SimpleDialog import SimpleDialog
-from .configHandler import idleConf
+from idlelib.configHandler import idleConf
     from codecs import BOM_UTF8
     def loadfile(self, filename):
             # open the file in binary mode so that we can handle
-            #   end-of-line convention ourselves.
+            # end-of-line convention ourselves.
             f = open(filename,'rb')
             chars = f.read()
         except IOError as msg:
             tkMessageBox.showerror("I/O Error", str(msg), master=self.text)
             return False
         chars = self.decode(chars)
         # We now convert all end-of-lines to '\n's
         firsteol = self.eol_re.search(chars)
                 # Make sure it is an ASCII string
                 self.eol_convention = self.eol_convention.encode("ascii")
             chars = self.eol_re.sub(r"\n", chars)
         self.text.delete("1.0", "end")
         self.text.insert("1.0", chars)
             self.opendialog = tkFileDialog.Open(master=self.text,
         filename = self.opendialog.show(initialdir=dir, initialfile=base)
-        if isinstance(filename, str):
-            filename = filename.encode(filesystemencoding)
+        assert isinstance(filename, str)
         return filename
     def defaultfilename(self, mode="open"):
     def updaterecentfileslist(self,filename):
         "Update recent file list on all editor windows"
-        self.editwin.update_recent_files_list(filename)
+        if self.editwin.flist:
+            self.editwin.update_recent_files_list(filename)
 def test():
     root = Tk()