Skip to content
Snippets Groups Projects
Commit fe25a79a authored by Guido Trotter's avatar Guido Trotter
Browse files

_ContainerFromDicts: handle None source


When _ContainerFromDicts is called on some element which doesn't exist
in the config, because it is yet to be upgraded, it will receive its
value as None. We take care of this case by using an empty element of
the required target type.

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 24a3707f
No related branches found
No related tags found
No related merge requests found
......@@ -202,6 +202,8 @@ class ConfigObject(object):
if not isinstance(c_type, type):
raise TypeError("Container type %s passed to _ContainerFromDicts is"
" not a type" % type(c_type))
if source is None:
source = c_type()
if c_type is dict:
ret = dict([(k, e_type.FromDict(v)) for k, v in source.iteritems()])
elif c_type in (list, tuple, set, frozenset):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment