Skip to content

Commit

Permalink
Fix crash in :config-dict-add, :config-dict-remove, :config-list-add …
Browse files Browse the repository at this point in the history
…and :config-list-remove with invalid option
  • Loading branch information
arza-zara committed Mar 17, 2019
1 parent 158b3be commit 58ac9b3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions qutebrowser/config/configcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ def config_list_add(self, option: str, value: str,
value: The value to append to the end of the list.
temp: Add value temporarily until qutebrowser is closed.
"""
opt = self._config.get_opt(option)
with self._handle_config_error():
opt = self._config.get_opt(option)
valid_list_types = (configtypes.List, configtypes.ListOrValue)
if not isinstance(opt.typ, valid_list_types):
raise cmdutils.CommandError(":config-list-add can only be used "
Expand All @@ -300,7 +301,8 @@ def config_dict_add(self, option: str, key: str, value: str,
replace: Replace existing values. By default, existing values are
not overwritten.
"""
opt = self._config.get_opt(option)
with self._handle_config_error():
opt = self._config.get_opt(option)
if not isinstance(opt.typ, configtypes.Dict):
raise cmdutils.CommandError(":config-dict-add can only be used "
"for dicts")
Expand All @@ -327,7 +329,8 @@ def config_list_remove(self, option: str, value: str,
value: The value to remove from the list.
temp: Remove value temporarily until qutebrowser is closed.
"""
opt = self._config.get_opt(option)
with self._handle_config_error():
opt = self._config.get_opt(option)
valid_list_types = (configtypes.List, configtypes.ListOrValue)
if not isinstance(opt.typ, valid_list_types):
raise cmdutils.CommandError(":config-list-remove can only be used "
Expand Down Expand Up @@ -355,7 +358,8 @@ def config_dict_remove(self, option: str, key: str,
key: The key to remove from the dict.
temp: Remove value temporarily until qutebrowser is closed.
"""
opt = self._config.get_opt(option)
with self._handle_config_error():
opt = self._config.get_opt(option)
if not isinstance(opt.typ, configtypes.Dict):
raise cmdutils.CommandError(":config-dict-remove can only be used "
"for dicts")
Expand Down

0 comments on commit 58ac9b3

Please sign in to comment.