Mercurial > hgrepos > Python > libs > ConfigMix
diff configmix/json.py @ 134:2f2e819e8d17
Check the return type of the JSON and YAML loading functions: they must be a dict alike
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Thu, 05 Apr 2018 09:12:29 +0200 |
| parents | df60417d7665 |
| children | e84870359e1a |
line wrap: on
line diff
--- a/configmix/json.py Wed Apr 04 23:51:07 2018 +0200 +++ b/configmix/json.py Thu Apr 05 09:12:29 2018 +0200 @@ -53,4 +53,7 @@ if _with_object_pairs_hook: kwds["object_pairs_hook"] = DictImpl decoder = json.decoder.JSONDecoder(**kwds) - return decoder.decode(jsfp.read()) + data = decoder.decode(jsfp.read()) + if not isinstance(data, DictImpl): + raise TypeError("JSON root must be an object") + return data
