--- a/src/eric7/Globals/__init__.py Tue Jan 24 10:16:03 2023 +0100 +++ b/src/eric7/Globals/__init__.py Wed Mar 01 09:05:47 2023 +0100 @@ -11,9 +11,9 @@ # Note: Do not import any eric stuff in here!!!!!!! # -import contextlib import os -import re + +import semver from PyQt6.QtCore import QByteArray, QCoreApplication, QProcess, qVersion @@ -55,13 +55,14 @@ settingsNameRecent = "eric7recent" # key names of the various recent entries -recentNameMultiProject = "MultiProjects" -recentNameProject = "Projects" +recentNameBreakpointConditions = "BreakPointConditions" +recentNameBreakpointFiles = "BreakPointFiles" recentNameFiles = "Files" recentNameHexFiles = "HexFiles" recentNameHosts = "Hosts" -recentNameBreakpointFiles = "BreakPointFiles" -recentNameBreakpointConditions = "BreakPointConditions" +recentNameMultiProject = "MultiProjects" +recentNamePdfFiles = "PdfFiles" +recentNameProject = "Projects" recentNameTestDiscoverHistory = "UTDiscoverHistory" recentNameTestFileHistory = "UTFileHistory" recentNameTestNameHistory = "UTTestnameHistory" @@ -132,21 +133,23 @@ @param version version string @type str - @param length desired length of the version tuple + @param length desired length of the version tuple (ignored) @type int - @return version tuple without the suffix - @rtype tuple of int + @return version named tuple containing the version parts + @rtype semver.VersionInfo """ - versionParts = [] + while version and not version[0].isdecimal(): + # sanitize version string (get rid of leading non-decimal characters) + version = version[1:] - # step 1: extract suffix - version = re.split(r"[^\d.]", version)[0] - for part in version.split("."): - with contextlib.suppress(ValueError): - versionParts.append(int(part.strip())) - versionParts.extend([0] * length) + if len(version.split(".")) < 3: + # ensure the version string contains at least three parts + version += ".0" - return tuple(versionParts[:length]) + if semver.VersionInfo.isvalid(version): + return semver.VersionInfo.parse(version) + else: + return semver.VersionInfo(0, 0, 0) ###############################################################################