VMM/Config: LazyConfigOption.__init__() cast 'default' to 'cls'. v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Fri, 12 Feb 2010 04:15:18 +0000
branchv0.6.x
changeset 201 dbb0f7ed7858
parent 200 983cf98d5881
child 202 43e7c8b440da
VMM/Config: LazyConfigOption.__init__() cast 'default' to 'cls'. If the default value is not None, make sure it has the proper type.
VirtualMailManager/Config.py
--- a/VirtualMailManager/Config.py	Thu Feb 11 07:20:49 2010 +0000
+++ b/VirtualMailManager/Config.py	Fri Feb 12 04:15:18 2010 +0000
@@ -247,7 +247,10 @@
             the value, when `LazyConfig.set()` is called.
         """
         self.__cls = cls
-        self.__default = default
+        if not default is None:# enforce the type of the default value
+            self.__default = self.__cls(default)
+        else:
+            self.__default = default
         if not callable(getter):
             raise TypeError('getter has to be a callable, got a %r' %
                             getter.__class__.__name__)