]> sigrok.org Git - libsigrok.git/commitdiff
python: ConfigInfo: return None from constructor if not available.
authorMartin Ling <redacted>
Tue, 17 Dec 2013 13:01:11 +0000 (13:01 +0000)
committerMartin Ling <redacted>
Tue, 17 Dec 2013 13:01:11 +0000 (13:01 +0000)
bindings/python/sigrok/core/classes.py

index 79be3b9f4270037e400c8de03cd14c166cf01317..5f38028ffae5be6e392dd8fa83cb46fad5764b18 100644 (file)
@@ -525,9 +525,14 @@ class Output(object):
 
 class ConfigInfo(object):
 
-    def __init__(self, key):
-        self.key = key
-        self.struct = sr_config_info_get(key.id)
+    def __new__(cls, key):
+        struct = sr_config_info_get(key.id)
+        if not struct:
+            return None
+        obj = super(ConfigInfo, cls).__new__(cls)
+        obj.key = key
+        obj.struct = struct
+        return obj
 
     @property
     def datatype(self):