From cd109f080729037db8ba517fb2b8b27586376c62 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sun, 17 Apr 2022 19:29:04 +1200 Subject: Add back PYQT_WEBENGINE_VERSION_STR workaround I had this in earlier but then didn't seem to need it. Now CI is failing. I though I had it with a WebKit install that had PyQtWebEngine installed as well (but not the C++ QtWebEngine). It could install PyQtWebEngine but didn't have anything in it. So if this works it might be a sign that more stuff will trip over it to come. For example `from PyQt5 import QtWebEngine` might work but `from PyQt5.QtWebEngine import PYQT_WEBENGINE_VERSION_STR` wouldn't. So we might be saddling ourselves with a false sense of security just switching on the top level stuff in the PyQt wrapper class. --- qutebrowser/utils/version.py | 6 +++--- tests/end2end/conftest.py | 2 +- tests/unit/utils/test_version.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 7e819e9ab..6ef9571d3 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -42,7 +42,7 @@ if QtWebKit: qWebKitVersion = QtWebKit.qWebKitVersion # noqa: N816 else: qWebKitVersion = None # noqa: N816 -if QtWebEngine: +if QtWebEngine and hasattr(QtWebEngine, 'PYQT_WEBENGINE_VERSION_STR'): PYQT_WEBENGINE_VERSION_STR = QtWebEngine.PYQT_WEBENGINE_VERSION_STR else: # Added in PyQt 5.13 @@ -758,8 +758,8 @@ def qtwebengine_versions(*, avoid_init: bool = False) -> WebEngineVersions: if pyqt_webengine_qt_version is not None: return WebEngineVersions.from_importlib(pyqt_webengine_qt_version) - if QtWebEngine.PYQT_WEBENGINE_VERSION_STR is not None: - return WebEngineVersions.from_pyqt(QtWebEngine.PYQT_WEBENGINE_VERSION_STR) + if PYQT_WEBENGINE_VERSION_STR is not None: + return WebEngineVersions.from_pyqt(PYQT_WEBENGINE_VERSION_STR) return WebEngineVersions.from_qt(QtCore.qVersion()) # type: ignore[unreachable] diff --git a/tests/end2end/conftest.py b/tests/end2end/conftest.py index d8d3b7a38..70053dc70 100644 --- a/tests/end2end/conftest.py +++ b/tests/end2end/conftest.py @@ -118,7 +118,7 @@ def _get_version_tag(tag): reason='Needs ' + tag, ) elif package == 'pyqtwebengine': - if QtWebEngine: + if QtWebEngine and hasattr(QtWebEngine, 'PYQT_WEBENGINE_VERSION_STR'): running_version = QtWebEngine.PYQT_WEBENGINE_VERSION else: running_version = QtCore.PYQT_VERSION diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py index 3ffb4cdea..6be73ec76 100644 --- a/tests/unit/utils/test_version.py +++ b/tests/unit/utils/test_version.py @@ -1097,7 +1097,7 @@ class TestChromiumVersion: @pytest.fixture def patch_old_pyqt(self, monkeypatch): """Simulate an old PyQt without PYQT_WEBENGINE_VERSION_STR.""" - monkeypatch.setattr(version.QtWebEngine, 'PYQT_WEBENGINE_VERSION_STR', None) + monkeypatch.setattr(version, 'PYQT_WEBENGINE_VERSION_STR', None) @pytest.fixture def patch_no_importlib(self, monkeypatch, stubs): -- cgit v1.2.3-54-g00ecf