From: Martin Ling Date: Tue, 17 Dec 2013 13:01:11 +0000 (+0000) Subject: python: ConfigInfo: return None from constructor if not available. X-Git-Tag: libsigrok-0.3.0~436 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=14e8eb33539dedf7760efff3165b3a0a1e09edbd;p=libsigrok.git python: ConfigInfo: return None from constructor if not available. --- diff --git a/bindings/python/sigrok/core/classes.py b/bindings/python/sigrok/core/classes.py index 79be3b9f..5f38028f 100644 --- a/bindings/python/sigrok/core/classes.py +++ b/bindings/python/sigrok/core/classes.py @@ -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):