(original) (raw)
changeset: 71678:7af576e3cb0c parent: 71676:4813fe208e29 parent: 71677:63bd8f42b511 user: Éric Araujo merwok@netwok.org date: Mon Aug 01 17:31:12 2011 +0200 description: Merge #12295 fix from 3.2 diff -r 4813fe208e29 -r 7af576e3cb0c Lib/idlelib/textView.py --- a/Lib/idlelib/textView.py Mon Aug 01 15:29:07 2011 +0200 +++ b/Lib/idlelib/textView.py Mon Aug 01 17:31:12 2011 +0200 @@ -62,14 +62,15 @@ def view_file(parent, title, filename, encoding=None): try: - textFile = open(filename, 'r', encoding=encoding) + with open(filename, 'r', encoding=encoding) as file: + contents = file.read() except IOError: import tkinter.messagebox as tkMessageBox tkMessageBox.showerror(title='File Load Error', message='Unable to load file %r .' % filename, parent=parent) else: - return view_text(parent, title, textFile.read()) + return view_text(parent, title, contents) if __name__ == '__main__': /merwok@netwok.org