eric6/Debugger/CallStackViewer.py

branch
multi_processing
changeset 7802
eefe954f01e8
parent 7377
cc920e534ac0
parent 7785
9978016560ec
child 7853
35dcac32984a
--- a/eric6/Debugger/CallStackViewer.py	Sun Jul 05 11:11:24 2020 +0200
+++ b/eric6/Debugger/CallStackViewer.py	Sun Oct 18 12:35:30 2020 +0200
@@ -7,7 +7,6 @@
 Module implementing the Call Stack viewer widget.
 """
 
-
 from PyQt5.QtCore import pyqtSignal, Qt, QFileInfo
 from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QMenu
 
@@ -180,13 +179,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