diff --git a/qutebrowser/browser/webpage.py b/qutebrowser/browser/webpage.py index 52448f0b9..b986304e8 100644 --- a/qutebrowser/browser/webpage.py +++ b/qutebrowser/browser/webpage.py @@ -17,6 +17,8 @@ """The main browser widgets.""" +import operator + import sip from PyQt5.QtCore import QCoreApplication, pyqtSignal, pyqtSlot, PYQT_VERSION from PyQt5.QtNetwork import QNetworkReply diff --git a/qutebrowser/utils/misc.py b/qutebrowser/utils/misc.py index e73ae68ab..27b06c441 100644 --- a/qutebrowser/utils/misc.py +++ b/qutebrowser/utils/misc.py @@ -27,11 +27,12 @@ import re import sys import shlex import os.path +import operator import urllib.request from urllib.parse import urljoin, urlencode from functools import reduce -from distutils.version import StrictVersion as Version +from distutils.version import StrictVersion as Version from PyQt5.QtCore import QCoreApplication, QStandardPaths, QEventLoop, qVersion from PyQt5.QtGui import QColor from pkg_resources import resource_string @@ -50,6 +51,16 @@ MINVALS = { } +def qt_version_check(version, op=operator.ge): + """Check if the Qt runtime version is the version supplied or newer. + + Args: + version: The version to check against. + op: The operator to use for the check. + """ + return op(Version(qVersion()), Version(version)) + + def elide(text, length): """Elide text so it uses a maximum of length chars.""" if length < 1: @@ -247,7 +258,7 @@ def actute_warning(): return # Qt >= 5.3 doesn't seem to be affected try: - if Version(qVersion()) >= Version('5.3.0'): + if qt_version_check('5.3.0'): return except ValueError: pass