mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 20:10:08 +01:00
Adding missing close for open and replaced "fid=open(filename) fid.close()"
statements with the safer "with open(filename) as fid:" blocks. Also removed unnecessary "try: ... finally: pass" statements and refactored code from img2py function into _write_image and _replace_non_alphanumeric_with_underscore Fixes #1574
This commit is contained in:
@@ -53,9 +53,8 @@ class NotebookFrame(wx.Frame):
|
||||
path = dlg.GetPath()
|
||||
|
||||
# Open the file as read-only and slurp its content
|
||||
fid = open(path, 'rt')
|
||||
text = fid.read()
|
||||
fid.close()
|
||||
with open(path, 'rt') as fid:
|
||||
text = fid.read()
|
||||
|
||||
# Create the notebook page as a wx.TextCtrl and
|
||||
# add it as a page of the wx.Notebook
|
||||
|
||||
@@ -53,9 +53,8 @@ class NotebookFrame(wx.Frame):
|
||||
path = dlg.GetPath()
|
||||
|
||||
# Open the file as read-only and slurp its content
|
||||
fid = open(path, 'rt')
|
||||
text = fid.read()
|
||||
fid.close()
|
||||
with open(path, 'rt') as fid:
|
||||
text = fid.read()
|
||||
|
||||
# Create the notebook page as a wx.TextCtrl and
|
||||
# add it as a page of the wx.Notebook
|
||||
|
||||
Reference in New Issue
Block a user