eric6/Debugger/CallStackViewer.py

changeset 7785
9978016560ec
parent 7780
41420f82c0ac
child 7802
eefe954f01e8
child 7836
2f0d208b8137
--- a/eric6/Debugger/CallStackViewer.py	Tue Oct 13 19:02:26 2020 +0200
+++ b/eric6/Debugger/CallStackViewer.py	Wed Oct 14 17:50:39 2020 +0200
@@ -178,13 +178,12 @@
                     fname = Utilities.toNativeSeparators(fname)
                 
                 try:
-                    f = open(fname, "w", encoding="utf-8")
-                    itm = self.topLevelItem(0)
-                    while itm is not None:
-                        f.write("{0}\n".format(itm.text(0)))
-                        f.write(78 * "=" + "\n")
-                        itm = self.itemBelow(itm)
-                    f.close()
+                    with open(fname, "w", encoding="utf-8") as f:
+                        itm = self.topLevelItem(0)
+                        while itm is not None:
+                            f.write("{0}\n".format(itm.text(0)))
+                            f.write(78 * "=" + "\n")
+                            itm = self.itemBelow(itm)
                 except IOError as err:
                     E5MessageBox.critical(
                         self,

eric ide

mercurial