Parcourir la source

empty list evaluates to False, so check for None explicitely

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jelte-configuration@826 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen il y a 15 ans
Parent
commit
7742c46239
1 fichiers modifiés avec 7 ajouts et 8 suppressions
  1. 7 8
      src/lib/config/python/isc/config/datadefinition.py

+ 7 - 8
src/lib/config/python/isc/config/datadefinition.py

@@ -65,7 +65,6 @@ class DataDefinition:
             if errors:
                 errors.append("The is no config_data for this specification")
             return False
-        errors = []
         return _validate_spec_list(data_def['config_data'], full, data, errors)
 
 
@@ -207,27 +206,27 @@ def _validate_type(spec, value, errors):
        specification"""
     data_type = spec['item_type']
     if data_type == "integer" and type(value) != int:
-        if errors:
+        if errors != None:
             errors.append(str(value) + " should be an integer")
         return False
     elif data_type == "real" and type(value) != float:
-        if errors:
+        if errors != None:
             errors.append(str(value) + " should be a real")
         return False
     elif data_type == "boolean" and type(value) != bool:
-        if errors:
+        if errors != None:
             errors.append(str(value) + " should be a boolean")
         return False
     elif data_type == "string" and type(value) != str:
-        if errors:
+        if errors != None:
             errors.append(str(value) + " should be a string")
         return False
     elif data_type == "list" and type(value) != list:
-        if errors:
+        if errors != None:
             errors.append(str(value) + " should be a list, not a " + str(value.__class__.__name__))
         return False
     elif data_type == "map" and type(value) != dict:
-        if errors:
+        if errors != None:
             errors.append(str(value) + " should be a map")
         return False
     else:
@@ -256,7 +255,7 @@ def _validate_spec(spec, full, data, errors):
     if item_name in data:
         return _validate_item(spec, data[item_name], errors)
     elif full and not item_optional:
-        if errors:
+        if errors != None:
             errors.append("non-optional item " + item_name + " missing")
         return False
     else: