eric7/Debugger/CallStackViewer.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 8881
54e42bc2437a
child 9153
506e35e424d5
--- a/eric7/Debugger/CallStackViewer.py	Wed Jun 15 09:44:07 2022 +0200
+++ b/eric7/Debugger/CallStackViewer.py	Thu Jun 16 18:28:59 2022 +0200
@@ -7,7 +7,9 @@
 Module implementing the Call Stack viewer widget.
 """
 
-from PyQt6.QtCore import pyqtSignal, Qt, QFileInfo
+import pathlib
+
+from PyQt6.QtCore import pyqtSignal, Qt
 from PyQt6.QtWidgets import (
     QTreeWidget, QTreeWidgetItem, QMenu, QWidget, QVBoxLayout, QLabel
 )
@@ -15,8 +17,6 @@
 from EricWidgets.EricApplication import ericApp
 from EricWidgets import EricFileDialog, EricMessageBox
 
-import Utilities
-
 
 class CallStackViewer(QWidget):
     """
@@ -196,26 +196,25 @@
                 None,
                 EricFileDialog.DontConfirmOverwrite)
             if fname:
-                ext = QFileInfo(fname).suffix()
-                if not ext:
+                fpath = pathlib.Path(fname)
+                if not fpath.suffix:
                     ex = selectedFilter.split("(*")[1].split(")")[0]
                     if ex:
-                        fname += ex
-                if QFileInfo(fname).exists():
+                        fpath = fpath.with_suffix(ex)
+                if fpath.exists():
                     res = EricMessageBox.yesNo(
                         self,
                         self.tr("Save Call Stack Info"),
                         self.tr("<p>The file <b>{0}</b> already exists."
-                                " Overwrite it?</p>").format(fname),
+                                " Overwrite it?</p>").format(str(fpath)),
                         icon=EricMessageBox.Warning)
                     if not res:
                         return
-                    fname = Utilities.toNativeSeparators(fname)
                 
                 try:
                     title = self.tr("Call Stack of '{0}'").format(
                         self.__debuggerLabel.text())
-                    with open(fname, "w", encoding="utf-8") as f:
+                    with fpath.open("w", encoding="utf-8") as f:
                         f.write("{0}\n".format(title))
                         f.write("{0}\n\n".format(len(title) * "="))
                         itm = self.__callStackList.topLevelItem(0)
@@ -230,4 +229,4 @@
                         self.tr("""<p>The call stack info could not be"""
                                 """ written to <b>{0}</b></p>"""
                                 """<p>Reason: {1}</p>""")
-                        .format(fname, str(err)))
+                        .format(str(fpath), str(err)))

eric ide

mercurial