Catch AttributeError for FormatString configtype

(cherry picked from commit b171f3c0f2)
This commit is contained in:
Florian Bruhin 2021-03-24 13:23:43 +01:00
parent 74903367ed
commit da0a1afad2
2 changed files with 3 additions and 1 deletions

View File

@ -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:

View File

@ -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):