Prevent loading non-dict vars (#5107)

This commit is contained in:
Saugat Pachhai
2020-12-15 19:21:31 +05:45
committed by GitHub
parent 11c94b10f2
commit 2512df7ca1
+6
View File
@@ -355,6 +355,12 @@ class Context(CtxDict):
loader = LOADERS[ext]
data = loader(path, tree=tree)
if not isinstance(data, Mapping):
typ = type(data).__name__
raise ContextError(
f"expected a dictionary, got '{typ}' in file '{file}'"
)
select_keys = select_keys or []
if select_keys:
try: