mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +00:00
Issue #18151: Replace remaining Idle 'open...close' pairs with 'with open'.
This commit is contained in:
parent
c86d7e989c
commit
95f34ab959
3 changed files with 10 additions and 17 deletions
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue