diff options
-rw-r--r-- | doc/changelog.asciidoc | 3 | ||||
-rw-r--r-- | misc/requirements/requirements-mypy.txt | 2 | ||||
-rw-r--r-- | misc/requirements/requirements-tests.txt | 8 | ||||
-rw-r--r-- | misc/requirements/requirements-tox.txt | 6 | ||||
-rw-r--r-- | misc/requirements/requirements-vulture.txt | 2 | ||||
-rw-r--r-- | qutebrowser/keyinput/basekeyparser.py | 17 | ||||
-rw-r--r-- | qutebrowser/utils/urlutils.py | 2 | ||||
-rw-r--r-- | tests/unit/keyinput/test_basekeyparser.py | 20 | ||||
-rw-r--r-- | tests/unit/utils/test_urlutils.py | 8 | ||||
-rw-r--r-- | tox.ini | 4 |
10 files changed, 53 insertions, 19 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 12416bcc2..8a5bb6ce3 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -24,6 +24,9 @@ Fixed - The "restore video" functionality of the `view_in_mpv` script works again on webengine. +- Setting `url.auto_search` to `dns` works correctly now with Qt 6. +- Counts passed via keypresses now have a digit limit (4300) to avoid + exceptions due to cats sleeping on numpads. (#7834) [[v3.0.0]] v3.0.0 (2023-08-18) diff --git a/misc/requirements/requirements-mypy.txt b/misc/requirements/requirements-mypy.txt index bcc196968..55585ad40 100644 --- a/misc/requirements/requirements-mypy.txt +++ b/misc/requirements/requirements-mypy.txt @@ -8,7 +8,7 @@ lxml==4.9.3 MarkupSafe==2.1.3 mypy==1.5.1 mypy-extensions==1.0.0 -pluggy==1.2.0 +pluggy==1.3.0 Pygments==2.16.1 PyQt5-stubs==5.15.6.0 tomli==2.0.1 diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt index 5d0597b8a..f49b0cf5f 100644 --- a/misc/requirements/requirements-tests.txt +++ b/misc/requirements/requirements-tests.txt @@ -11,14 +11,14 @@ coverage==7.3.0 exceptiongroup==1.1.3 execnet==2.0.2 filelock==3.12.2 -Flask==2.3.2 +Flask==2.3.3 hunter==3.6.1 hypothesis==6.82.6 idna==3.4 importlib-metadata==6.8.0 iniconfig==2.0.0 itsdangerous==2.1.2 -jaraco.functools==3.8.1 +jaraco.functools==3.9.0 # Jinja2==3.1.2 Mako==1.2.4 manhole==1.8.0 @@ -27,7 +27,7 @@ more-itertools==10.1.0 packaging==23.1 parse==1.19.1 parse-type==0.6.2 -pluggy==1.2.0 +pluggy==1.3.0 py-cpuinfo==9.0.0 Pygments==2.16.1 pytest==7.4.0 @@ -52,6 +52,6 @@ toml==0.10.2 tomli==2.0.1 typing_extensions==4.7.1 urllib3==2.0.4 -vulture==2.9 +vulture==2.9.1 Werkzeug==2.3.7 zipp==3.16.2 diff --git a/misc/requirements/requirements-tox.txt b/misc/requirements/requirements-tox.txt index a4b321d60..ef2f11955 100644 --- a/misc/requirements/requirements-tox.txt +++ b/misc/requirements/requirements-tox.txt @@ -8,10 +8,10 @@ filelock==3.12.2 packaging==23.1 pip==23.2.1 platformdirs==3.10.0 -pluggy==1.2.0 +pluggy==1.3.0 pyproject-api==1.5.4 setuptools==68.1.2 tomli==2.0.1 -tox==4.9.0 +tox==4.10.0 virtualenv==20.24.3 -wheel==0.41.1 +wheel==0.41.2 diff --git a/misc/requirements/requirements-vulture.txt b/misc/requirements/requirements-vulture.txt index a3545aa1c..1d091baf3 100644 --- a/misc/requirements/requirements-vulture.txt +++ b/misc/requirements/requirements-vulture.txt @@ -1,4 +1,4 @@ # This file is automatically generated by scripts/dev/recompile_requirements.py toml==0.10.2 -vulture==2.9 +vulture==2.9.1 diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py index 8c8ca4613..df6b66f7f 100644 --- a/qutebrowser/keyinput/basekeyparser.py +++ b/qutebrowser/keyinput/basekeyparser.py @@ -7,13 +7,14 @@ import string import types import dataclasses +import traceback from typing import Mapping, MutableMapping, Optional, Sequence from qutebrowser.qt.core import QObject, pyqtSignal from qutebrowser.qt.gui import QKeySequence, QKeyEvent from qutebrowser.config import config -from qutebrowser.utils import log, usertypes, utils +from qutebrowser.utils import log, usertypes, utils, message from qutebrowser.keyinput import keyutils @@ -189,7 +190,7 @@ class BaseKeyParser(QObject): passthrough=self.passthrough, supports_count=self._supports_count) - def _debug_log(self, message: str) -> None: + def _debug_log(self, msg: str) -> None: """Log a message to the debug log if logging is active. Args: @@ -198,7 +199,7 @@ class BaseKeyParser(QObject): if self._do_log: prefix = '{} for mode {}: '.format(self.__class__.__name__, self._mode.name) - log.keyboard.debug(prefix + message) + log.keyboard.debug(prefix + msg) def _match_key(self, sequence: keyutils.KeySequence) -> MatchResult: """Try to match a given keystring with any bound keychain. @@ -315,7 +316,15 @@ class BaseKeyParser(QObject): assert result.command is not None self._debug_log("Definitive match for '{}'.".format( result.sequence)) - count = int(self._count) if self._count else None + + try: + count = int(self._count) if self._count else None + except ValueError as err: + message.error(f"Failed to parse count: {err}", + stack=traceback.format_exc()) + self.clear_keystring() + return + self.clear_keystring() self.execute(result.command, count) elif result.match_type == QKeySequence.SequenceMatch.PartialMatch: diff --git a/qutebrowser/utils/urlutils.py b/qutebrowser/utils/urlutils.py index 0b571946d..7b613c0a2 100644 --- a/qutebrowser/utils/urlutils.py +++ b/qutebrowser/utils/urlutils.py @@ -226,7 +226,7 @@ def _is_url_dns(urlstr: str) -> bool: return False log.url.debug("Doing DNS request for {}".format(host)) info = QHostInfo.fromName(host) - return not info.error() + return info.error() == QHostInfo.HostInfoError.NoError def fuzzy_url(urlstr: str, diff --git a/tests/unit/keyinput/test_basekeyparser.py b/tests/unit/keyinput/test_basekeyparser.py index 68239d4b4..ec7c225bf 100644 --- a/tests/unit/keyinput/test_basekeyparser.py +++ b/tests/unit/keyinput/test_basekeyparser.py @@ -4,6 +4,9 @@ """Tests for BaseKeyParser.""" +import logging +import re +import sys from unittest import mock from qutebrowser.qt.core import Qt @@ -342,3 +345,20 @@ def test_respect_config_when_matching_counts(keyparser, config_stub): assert not keyparser._sequence assert not keyparser._count + + +def test_count_limit_exceeded(handle_text, keyparser, caplog): + try: + max_digits = sys.get_int_max_str_digits() + except AttributeError: + pytest.skip('sys.get_int_max_str_digits() not available') + + keys = (max_digits + 1) * [Qt.Key.Key_1] + + with caplog.at_level(logging.ERROR): + handle_text(keyparser, *keys, Qt.Key.Key_B, Qt.Key.Key_A) + + pattern = re.compile(r"^Failed to parse count: Exceeds the limit .* for integer string conversion: .*") + assert any(pattern.fullmatch(msg) for msg in caplog.messages) + assert not keyparser._sequence + assert not keyparser._count diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py index bbd55e36c..d2eab5928 100644 --- a/tests/unit/utils/test_urlutils.py +++ b/tests/unit/utils/test_urlutils.py @@ -10,7 +10,7 @@ import dataclasses import urllib.parse from qutebrowser.qt.core import QUrl -from qutebrowser.qt.network import QNetworkProxy +from qutebrowser.qt.network import QNetworkProxy, QHostInfo import pytest import hypothesis import hypothesis.strategies @@ -38,7 +38,7 @@ class FakeDNS: @dataclasses.dataclass class FakeDNSAnswer: - error: bool + error: QHostInfo.HostInfoError def __init__(self): self.used = False @@ -53,7 +53,9 @@ class FakeDNS: self.answer = None def _get_error(self): - return not self.answer + if self.answer: + return QHostInfo.HostInfoError.NoError + return QHostInfo.HostInfoError.HostNotFound def fromname_mock(self, _host): """Simple mock for QHostInfo::fromName returning a FakeDNSAnswer.""" @@ -70,8 +70,8 @@ setenv = pip_pre = true deps = -r{toxinidir}/misc/requirements/requirements-tests-bleeding.txt commands_pre = - qt5: pip install --index-url https://www.riverbankcomputing.com/pypi/simple/ --pre --upgrade PyQt5 PyQtWebEngine PyQt5-Qt5 PyQtWebEngine-Qt5 PyQt5-sip - !qt5: pip install --index-url https://www.riverbankcomputing.com/pypi/simple/ --pre --upgrade PyQt6 PyQt6-WebEngine PyQt6-Qt6 PyQt6-WebEngine-Qt6 PyQt6-sip + qt5: pip install --extra-index-url https://www.riverbankcomputing.com/pypi/simple/ --pre --upgrade PyQt5 PyQtWebEngine PyQt5-Qt5 PyQtWebEngine-Qt5 PyQt5-sip + !qt5: pip install --extra-index-url https://www.riverbankcomputing.com/pypi/simple/ --pre --upgrade PyQt6 PyQt6-WebEngine PyQt6-Qt6 PyQt6-WebEngine-Qt6 PyQt6-sip commands = {envpython} -bb -m pytest {posargs:tests} # other envs |