From fe25a79ab804927d549c1486745ab14f97fc8ee9 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 13 Sep 2010 17:49:17 +0100
Subject: [PATCH] _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: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/objects.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/objects.py b/lib/objects.py
index 7af8506b1..04ad41565 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -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):
-- 
GitLab