[Python-checkins] cpython (3.2): Fix resource warning when looking at turtledemo’s help (#12295)
eric.araujo
python-checkins at python.org
Mon Aug 1 17:31:47 CEST 2011
http://hg.python.org/cpython/rev/63bd8f42b511
changeset: 71677:63bd8f42b511
branch: 3.2
parent: 71669:da79c5d0ed17
user: Éric Araujo <merwok at netwok.org>
date: Mon Aug 01 17:29:36 2011 +0200
summary:
Fix resource warning when looking at turtledemo’s help (#12295)
files:
Lib/idlelib/textView.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py
--- a/Lib/idlelib/textView.py
+++ b/Lib/idlelib/textView.py
@@ -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__':
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list