eric7/Debugger/CallTraceViewer.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 8881
54e42bc2437a
child 9153
506e35e424d5
diff -r 8c5296fe3056 -r 8a68afaf1ba2 eric7/Debugger/CallTraceViewer.py
--- a/eric7/Debugger/CallTraceViewer.py	Wed Jun 15 09:44:07 2022 +0200
+++ b/eric7/Debugger/CallTraceViewer.py	Thu Jun 16 18:28:59 2022 +0200
@@ -7,9 +7,10 @@
 Module implementing the Call Trace viewer widget.
 """
 
+import pathlib
 import re
 
-from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt, QFileInfo
+from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt
 from PyQt6.QtWidgets import QWidget, QTreeWidgetItem
 
 from EricWidgets.EricApplication import ericApp
@@ -19,7 +20,6 @@
 
 import UI.PixmapCache
 import Preferences
-import Utilities
 
 
 class CallTraceViewer(QWidget, Ui_CallTraceViewer):
@@ -160,26 +160,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 Trace 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 Trace Info of '{0}'").format(
                         self.__tracedDebuggerId)
-                    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.callTrace.topLevelItem(0)
@@ -197,7 +196,7 @@
                         self.tr("""<p>The call trace info could not"""
                                 """ be written to <b>{0}</b></p>"""
                                 """<p>Reason: {1}</p>""")
-                        .format(fname, str(err)))
+                        .format(str(fpath), str(err)))
     
     @pyqtSlot(QTreeWidgetItem, int)
     def on_callTrace_itemDoubleClicked(self, item, column):

eric ide

mercurial