summaryrefslogtreecommitdiff
path: root/Lib/idlelib/ScriptBinding.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2013-08-04 15:39:03 -0400
committerTerry Jan Reedy <tjreedy@udel.edu>2013-08-04 15:39:03 -0400
commit95f34ab95959fa67d258043622744dae8519c5b2 (patch)
tree3fbbe3a8bf381438abfc71fd5613e883b55dc4cf /Lib/idlelib/ScriptBinding.py
parentc86d7e989c98d57449263201e826a52c15102a64 (diff)
downloadcpython-git-95f34ab95959fa67d258043622744dae8519c5b2.tar.gz
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 528adf67a6..6bfe128e3c 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, 'rb')
- source = f.read()
- f.close()
+ with open(filename, 'rb') as f:
+ source = f.read()
if b'\r' in source:
source = source.replace(b'\r\n', b'\n')
source = source.replace(b'\r', b'\n')