mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 20:10:08 +01:00
Fixes issue 1571:
Adding missing close for open. If the "close()" call is missing after a "open(filename)" call, the filename isn't guaranteed to be closed before the interpreter exits. This is generally a bad practice as explained here: https://stackoverflow.com/questions/7395542/is-explicitly-closing-files-important Also replaced "fid=open(filename) fid.close()" statements for files with the safer "with open(filename) as fid:" blocks. See https://www.python.org/dev/peps/pep-0343/
This commit is contained in:
@@ -157,12 +157,12 @@ class RulerCtrlDemo(wx.Frame):
|
||||
|
||||
self.stc = PythonSTC(self.panel, -1)
|
||||
try:
|
||||
fid = open("RulerCtrl.py", "rt")
|
||||
with open("RulerCtrl.py", "rt") as fid:
|
||||
text = fid.read()
|
||||
except:
|
||||
fid = open("agw/RulerCtrl.py", "rt")
|
||||
with open("agw/RulerCtrl.py", "rt") as fid:
|
||||
text = fid.read()
|
||||
|
||||
text = fid.read()
|
||||
fid.close()
|
||||
self.stc.SetValue(text)
|
||||
|
||||
self.ruler1 = RC.RulerCtrl(self.panel, -1, orient=wx.HORIZONTAL, style=wx.SUNKEN_BORDER)
|
||||
|
||||
@@ -387,8 +387,8 @@ def runTest(frame, nb, log):
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
overview = open(HTML_HELP, 'rt').read()
|
||||
with open(HTML_HELP, 'rt') as fid:
|
||||
overview = fid.read()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user