summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/ScriptBinding.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2013-08-04 19:39:56 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2013-08-04 19:39:56 (GMT)
commitf9489436041b319ffab52eb1769d11849d68129d (patch)
tree4e54d54e1ebc435138eb8b5829bc97a39d77a09c /Lib/idlelib/ScriptBinding.py
parentb67170114949f13c1eacf6d58a06482bb7b78dd0 (diff)
downloadcpython-f9489436041b319ffab52eb1769d11849d68129d.zip
cpython-f9489436041b319ffab52eb1769d11849d68129d.tar.gz
cpython-f9489436041b319ffab52eb1769d11849d68129d.tar.bz2
Issue #18151: Replace remaining Idle 'open...close' pairs with 'with open'.
Diffstat (limited to 'Lib/idlelib/ScriptBinding.py')
-rw-r--r--Lib/idlelib/ScriptBinding.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py
index 665b3b2..a024ebf 100644
--- a/Lib/idlelib/ScriptBinding.py
+++ b/Lib/idlelib/ScriptBinding.py
@@ -87,9 +87,8 @@ class ScriptBinding:
self.shell = shell = self.flist.open_shell()
saved_stream = shell.get_warning_stream()
shell.set_warning_stream(shell.stderr)
- f = open(filename, 'r')
- source = f.read()
- f.close()
+ with open(filename, 'r') as f:
+ source = f.read()
if '\r' in source:
source = re.sub(r"\r\n", "\n", source)
source = re.sub(r"\r", "\n", source)