--- a/eric7/QScintilla/Shell.py Wed Jun 15 09:44:07 2022 +0200 +++ b/eric7/QScintilla/Shell.py Thu Jun 16 18:28:59 2022 +0200 @@ -11,8 +11,9 @@ import re import contextlib import enum +import pathlib -from PyQt6.QtCore import pyqtSignal, pyqtSlot, QFileInfo, Qt, QEvent +from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QEvent from PyQt6.QtGui import QClipboard, QPalette, QFont, QShortcut from PyQt6.QtWidgets import ( QDialog, QInputDialog, QApplication, QMenu, QWidget, QHBoxLayout, @@ -2197,7 +2198,7 @@ for url in event.mimeData().urls(): fname = url.toLocalFile() if fname: - if not QFileInfo(fname).isDir(): + if not pathlib.Path(fname).is_dir(): self.vm.openSourceFile(fname) else: EricMessageBox.information( @@ -2399,23 +2400,22 @@ if fn.endswith("."): fn = fn[:-1] - ext = QFileInfo(fn).suffix() - if not ext: + fpath = pathlib.Path(fn) + if not fpath.suffix: ex = selectedFilter.split("(*")[1].split(")")[0] if ex: - fn += ex - if QFileInfo(fn).exists(): + fpath = fpath.with_suffix(ex) + if fpath.exists(): res = EricMessageBox.yesNo( self, self.tr("Save Shell Contents"), self.tr("<p>The file <b>{0}</b> already exists." - " Overwrite it?</p>").format(fn), + " Overwrite it?</p>").format(str(fpath)), icon=EricMessageBox.Warning) if not res: return - fn = Utilities.toNativeSeparators(fn) try: - with open(fn, "w", encoding="utf-8") as f: + with fpath.open("w", encoding="utf-8") as f: f.write(txt) except (OSError, UnicodeError) as why: EricMessageBox.critical( @@ -2423,7 +2423,7 @@ self.tr("Save Shell Contents"), self.tr('<p>The file <b>{0}</b> could not be saved.<br/>' 'Reason: {1}</p>') - .format(fn, str(why))) + .format(str(fpath), str(why))) ################################################################# ## Project Support