From 4ea7872ba4ef4be5a01ff6bdd5182a244263dc24 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Mon, 26 Mar 2012 22:56:10 +0200 Subject: [PATCH] fix setting None, NotLoaded and NotAvailable values on fields --- weboob/capabilities/base.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/weboob/capabilities/base.py b/weboob/capabilities/base.py index ccda5a61..3844ac1f 100644 --- a/weboob/capabilities/base.py +++ b/weboob/capabilities/base.py @@ -313,14 +313,16 @@ class CapBaseObject(object): except KeyError: object.__setattr__(self, name, value) else: - try: - # Try to convert value to the wanted one. - value = attr.convert(value) - except Exception: - # error during conversion, it will probably not - # match the wanted following types, so we'll - # raise ValueError. - pass + if value not in (NotLoaded, NotAvailable, None): + try: + # Try to convert value to the wanted one. + value = attr.convert(value) + except Exception: + # error during conversion, it will probably not + # match the wanted following types, so we'll + # raise ValueError. + pass + if not isinstance(value, attr.types) and \ value is not NotLoaded and \ value is not NotAvailable and \