X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fvalue.py;fp=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fvalue.py;h=6cea6cd59a69f88fdfd043179750d48ab5b64f16;hb=665658c2f8c04a8616e0f95ffa5d56e8c12f9668;hp=81a72ffa785e7d735736e839714c30db69dfd315;hpb=91189aebe7163493f81e839b1e8517dcd43d65bd;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/value.py b/src/bindings/python/bt2/bt2/value.py index 81a72ffa..6cea6cd5 100644 --- a/src/bindings/python/bt2/bt2/value.py +++ b/src/bindings/python/bt2/bt2/value.py @@ -63,24 +63,20 @@ def create_value(value): if isinstance(value, bool): return BoolValue(value) - if isinstance(value, int): + if isinstance(value, numbers.Integral): return SignedIntegerValue(value) - if isinstance(value, float): + if isinstance(value, numbers.Real): return RealValue(value) if isinstance(value, str): return StringValue(value) - try: - return MapValue(value) - except: - pass - - try: + if isinstance(value, collections.abc.Sequence): return ArrayValue(value) - except: - pass + + if isinstance(value, collections.abc.Mapping): + return MapValue(value) raise TypeError("cannot create value object from '{}' object".format(value.__class__.__name__))