diff -r 90939b08da20 -r 8b75b1668583 eric7/WebBrowser/Tools/WebBrowserTools.py --- a/eric7/WebBrowser/Tools/WebBrowserTools.py Mon Jun 20 13:25:14 2022 +0200 +++ b/eric7/WebBrowser/Tools/WebBrowserTools.py Mon Jun 20 19:47:39 2022 +0200 @@ -12,7 +12,7 @@ import mimetypes from PyQt6.QtCore import ( - QFile, QByteArray, QUrl, QCoreApplication, QBuffer, QIODevice + QByteArray, QUrl, QCoreApplication, QBuffer, QIODevice ) from PyQt6.QtGui import QPixmap @@ -33,25 +33,11 @@ @return contents of the file @rtype str """ - return str(readAllFileByteContents(filename), encoding="utf-8") - - -def readAllFileByteContents(filename): - """ - Function to read the bytes contents of the given file. - - @param filename name of the file - @type str - @return contents of the file - @rtype str - """ - dataFile = QFile(filename) - if filename and dataFile.open(QIODevice.OpenModeFlag.ReadOnly): - contents = dataFile.readAll() - dataFile.close() - return contents - - return QByteArray() + try: + with open(filename, "r", encoding="utf-8") as f: + return f.read() + except OSError: + return "" def containsSpace(string):