diff options
author | Éric Araujo <merwok@netwok.org> | 2011-08-01 15:31:12 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-08-01 15:31:12 (GMT) |
commit | eec1ed81192e856ada3fab4d13aaea7d7a581f0a (patch) | |
tree | 27ada60eeddee62ac698a1070b3634f68e06dbd5 /Lib/idlelib | |
parent | cee6bb549946bb096aa380a49f3b11daf2d8713e (diff) | |
parent | ccf03a1cdcf1f108ca41b4f60821de40c1b695e2 (diff) | |
download | cpython-eec1ed81192e856ada3fab4d13aaea7d7a581f0a.zip cpython-eec1ed81192e856ada3fab4d13aaea7d7a581f0a.tar.gz cpython-eec1ed81192e856ada3fab4d13aaea7d7a581f0a.tar.bz2 |
Merge #12295 fix from 3.2
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/textView.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py index e5c551a..e0f49d4 100644 --- a/Lib/idlelib/textView.py +++ b/Lib/idlelib/textView.py @@ -62,14 +62,15 @@ def view_text(parent, title, text): 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__': |