mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 14:58:38 +00:00
config: don't crash with a config file containing only comments
This commit is contained in:
parent
06cb68c799
commit
d95f28e6bf
@ -432,6 +432,8 @@ def parse(text):
|
||||
raise exceptions.OptionsError("Could not parse options.")
|
||||
if isinstance(data, str):
|
||||
raise exceptions.OptionsError("Config error - no keys found.")
|
||||
elif data is None:
|
||||
return {}
|
||||
return data
|
||||
|
||||
|
||||
|
@ -257,6 +257,10 @@ def test_serialize():
|
||||
with pytest.raises(Exception, match="Config error"):
|
||||
optmanager.load(o2, t)
|
||||
|
||||
t = "# a comment"
|
||||
optmanager.load(o2, t)
|
||||
assert optmanager.load(o2, "foobar: '123'") == {"foobar": "123"}
|
||||
|
||||
t = ""
|
||||
optmanager.load(o2, t)
|
||||
assert optmanager.load(o2, "foobar: '123'") == {"foobar": "123"}
|
||||
|
Loading…
Reference in New Issue
Block a user