eric6/DebugClients/Python/DebugClientBase.py

changeset 7785
9978016560ec
parent 7775
4a1db75550bd
child 7802
eefe954f01e8
child 7803
97f77d69c6f0
--- a/eric6/DebugClients/Python/DebugClientBase.py	Tue Oct 13 19:02:26 2020 +0200
+++ b/eric6/DebugClients/Python/DebugClientBase.py	Wed Oct 14 17:50:39 2020 +0200
@@ -220,11 +220,10 @@
         else:
             default = 'utf-8'
             try:
-                f = open(filename, 'rb')
-                # read the first and second line
-                text = f.readline()
-                text = "{0}{1}".format(text, f.readline())
-                f.close()
+                with open(filename, 'rb') as f:
+                    # read the first and second line
+                    text = f.readline()
+                    text = "{0}{1}".format(text, f.readline())
             except IOError:
                 self.__coding = default
                 return

eric ide

mercurial