diff -r 9117c08e4707 -r dc7f25f2f7e4 src/eric7/QScintilla/Editor.py --- a/src/eric7/QScintilla/Editor.py Tue Jul 09 14:09:40 2024 +0200 +++ b/src/eric7/QScintilla/Editor.py Tue Jul 09 17:20:18 2024 +0200 @@ -1999,10 +1999,7 @@ language = Preferences.getEditorLexerAssoc(bindName) if language == "Python": # correction for Python - pyVer = PythonUtilities.determinePythonVersion( - filename, self.text(0), self - ) - language = "Python{0}".format(pyVer) + language = "Python3" if language in [ "Python3", "MicroPython", @@ -2154,9 +2151,8 @@ filename = os.path.basename(filename) apiLanguage = Preferences.getEditorLexerAssoc(filename) if apiLanguage == "": - pyVer = self.__getPyVersion() - if pyVer: - apiLanguage = "Python{0}".format(pyVer) + if PythonUtilities.isPythonSource(self.fileName, self.text(0), self): + apiLanguage = "Python3" elif self.isRubyFile(): apiLanguage = "Ruby" @@ -2302,9 +2298,8 @@ """ ftype = self.filetype if not ftype: - pyVer = self.__getPyVersion() - if pyVer: - ftype = "Python{0}".format(pyVer) + if PythonUtilities.isPythonSource(self.fileName, self.text(0), self): + ftype = "Python3" elif self.isRubyFile(): ftype = "Ruby" else: @@ -2321,16 +2316,6 @@ """ return self.encoding - def __getPyVersion(self): - """ - Private method to return the Python main version or 0 if it's - not a Python file at all. - - @return Python version or 0 if it's not a Python file - @rtype int - """ - return PythonUtilities.determinePythonVersion(self.fileName, self.text(0), self) - def isPyFile(self): """ Public method to return a flag indicating a Python (2 or 3) file. @@ -2338,7 +2323,7 @@ @return flag indicating a Python3 file @rtype bool """ - return self.__getPyVersion() == 3 + return PythonUtilities.isPythonSource(self.fileName, self.text(0), self) def isPy3File(self): """ @@ -2347,7 +2332,7 @@ @return flag indicating a Python3 file @rtype bool """ - return self.__getPyVersion() == 3 + return PythonUtilities.isPythonSource(self.fileName, self.text(0), self) def isMicroPythonFile(self): """