diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2013-08-04 19:39:56 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2013-08-04 19:39:56 (GMT) |
commit | f9489436041b319ffab52eb1769d11849d68129d (patch) | |
tree | 4e54d54e1ebc435138eb8b5829bc97a39d77a09c /Lib/idlelib/ScriptBinding.py | |
parent | b67170114949f13c1eacf6d58a06482bb7b78dd0 (diff) | |
download | cpython-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.py | 5 |
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) |