summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-03-24 13:23:43 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-03-24 13:25:19 +0100
commitda0a1afad2a71a01e7665dd8eada834c98a23345 (patch)
tree6b2fb08857e783468bb5be25ea4f5869448b4ba9
parent74903367edcbc516dd189a6333b551f1b376aec6 (diff)
downloadqutebrowser-da0a1afad2a71a01e7665dd8eada834c98a23345.tar.gz
qutebrowser-da0a1afad2a71a01e7665dd8eada834c98a23345.zip
Catch AttributeError for FormatString configtype
(cherry picked from commit b171f3c0f2bd52f30330843a742d4bf9600b420d)
-rw-r--r--qutebrowser/config/configtypes.py2
-rw-r--r--tests/unit/config/test_configtypes.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py
index cc3f10ceb..49a1f0356 100644
--- a/qutebrowser/config/configtypes.py
+++ b/qutebrowser/config/configtypes.py
@@ -1567,7 +1567,7 @@ class FormatString(BaseType):
try:
value.format(**{k: '' for k in self.fields})
- except (KeyError, IndexError) as e:
+ except (KeyError, IndexError, AttributeError) as e:
raise configexc.ValidationError(value, "Invalid placeholder "
"{}".format(e))
except ValueError as e:
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index 1a0a9cb43..28c52a1e0 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -1832,6 +1832,8 @@ class TestFormatString:
'{foo} {bar} {baz}',
'{foo} {bar',
'{1}',
+ '{foo.attr}',
+ '{foo[999]}',
])
def test_to_py_invalid(self, typ, val):
with pytest.raises(configexc.ValidationError):