From 506eeb72776ef95827c1dfa3ed0aa55897574952 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 1 Oct 2019 15:27:51 +0200 Subject: Allow using config.bind(key, None) but deprecate it Using config.bind(key, None) in a config.py file never was supposed to be possible. However, it worked by accident until v1.7.0, where it then broke because of 9ed6aaaa1646fad0710ba28bf12bd8eb9e011a72. Also, note that :config-py-write also emitted such invalid lines, which was fixed in v1.8.0 in #4949. (cherry picked from commit 2033ed1955b642cbcd2bc4ea88d361c340fb3d38) --- doc/changelog.asciidoc | 13 +++++++++++++ qutebrowser/config/configfiles.py | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index de6a2f33e..dd183a29c 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -15,6 +15,19 @@ breaking changes (such as renamed commands) can happen in minor releases. // `Fixed` for any bug fixes. // `Security` to invite users to upgrade in case of vulnerabilities. +v1.9.0 (unreleased) +------------------- + +Fixed +~~~~~ + +- dictcli.py now works correctly on Windows again. +- Unbinding keys via `config.bind(key, None)` accidentally worked in + v1.7.0 but raises an exception in v1.8.0. It now works again, but is + deprecated and shows an error. Note that `:config-py-write` did write + such invalid lines before v1.8.0, so existing config files might need + adjustments. + v1.8.1 (2019-09-27) ------------------- diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index e7066fa11..f220d2ca4 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -442,11 +442,21 @@ class ConfigAPI: urlpattern = urlmatch.UrlPattern(pattern) if pattern else None self._config.set_obj(name, value, pattern=urlpattern) - def bind(self, key: str, command: str, mode: str = 'normal') -> None: + def bind(self, key: str, + command: typing.Optional[str], + mode: str = 'normal') -> None: """Bind a key to a command, with an optional key mode.""" with self._handle_error('binding', key): seq = keyutils.KeySequence.parse(key) - self._keyconfig.bind(seq, command, mode=mode) + if command is None: + text = ("Unbinding commands with config.bind('{key}', None) " + "is deprecated. Use config.unbind('{key}') instead." + .format(key=key)) + self.errors.append(configexc.ConfigErrorDesc( + "While unbinding '{}'".format(key), text)) + self._keyconfig.unbind(seq, mode=mode) + else: + self._keyconfig.bind(seq, command, mode=mode) def unbind(self, key: str, mode: str = 'normal') -> None: """Unbind a key from a command, with an optional key mode.""" -- cgit v1.2.3-54-g00ecf