python: fix all "do not use bare 'except'" warnings
[babeltrace.git] / src / bindings / python / bt2 / bt2 / value.py
index 3c883f76e6189c42583c57b80b09a5062f3ecfb7..3001502abb472600a8038d1d056c19197a8c374b 100644 (file)
@@ -37,7 +37,7 @@ def _create_from_ptr(ptr):
     # to it that we are not going to manage anymore, since we don't create a
     # Python wrapper for it.  Therefore put that reference immediately.
     if ptr == native_bt.value_null:
-        bt2.value._Value._put_ref(ptr)
+        _Value._put_ref(ptr)
         return
 
     typeid = native_bt.value_get_type(ptr)
@@ -92,7 +92,7 @@ class _Value(object._SharedObject, metaclass=abc.ABCMeta):
 
     def _check_create_status(self, ptr):
         if ptr is None:
-            raise bt2.CreationError(
+            raise bt2._MemoryError(
                 'cannot create {} value object'.format(self._NAME.lower())
             )
 
@@ -132,7 +132,7 @@ class _NumericValue(_Value):
     def __eq__(self, other):
         try:
             return self._value == self._extract_value(other)
-        except:
+        except Exception:
             return False
 
     def __rmod__(self, other):
@@ -307,18 +307,18 @@ class _IntegerValue(_IntegralValue):
 
 class UnsignedIntegerValue(_IntegerValue):
     _check_int_range = staticmethod(utils._check_uint64)
-    _create_default_value = staticmethod(native_bt.value_unsigned_integer_create)
-    _create_value = staticmethod(native_bt.value_unsigned_integer_create_init)
-    _set_value = staticmethod(native_bt.value_unsigned_integer_set)
-    _get_value = staticmethod(native_bt.value_unsigned_integer_get)
+    _create_default_value = staticmethod(native_bt.value_integer_unsigned_create)
+    _create_value = staticmethod(native_bt.value_integer_unsigned_create_init)
+    _set_value = staticmethod(native_bt.value_integer_unsigned_set)
+    _get_value = staticmethod(native_bt.value_integer_unsigned_get)
 
 
 class SignedIntegerValue(_IntegerValue):
     _check_int_range = staticmethod(utils._check_int64)
-    _create_default_value = staticmethod(native_bt.value_signed_integer_create)
-    _create_value = staticmethod(native_bt.value_signed_integer_create_init)
-    _set_value = staticmethod(native_bt.value_signed_integer_set)
-    _get_value = staticmethod(native_bt.value_signed_integer_get)
+    _create_default_value = staticmethod(native_bt.value_integer_signed_create)
+    _create_value = staticmethod(native_bt.value_integer_signed_create_init)
+    _set_value = staticmethod(native_bt.value_integer_signed_set)
+    _get_value = staticmethod(native_bt.value_integer_signed_get)
 
 
 class RealValue(_RealValue):
@@ -383,7 +383,7 @@ class StringValue(collections.abc.Sequence, _Value):
     def __eq__(self, other):
         try:
             return self._value == self._value_to_str(other)
-        except:
+        except Exception:
             return False
 
     def __lt__(self, other):
@@ -404,6 +404,9 @@ class StringValue(collections.abc.Sequence, _Value):
     def __len__(self):
         return len(self._value)
 
+    def __contains__(self, item):
+        return self._value_to_str(item) in self._value
+
     def __iadd__(self, value):
         curvalue = self._value
         curvalue += self._value_to_str(value)
@@ -448,7 +451,7 @@ class ArrayValue(_Container, collections.abc.MutableSequence, _Value):
         return True
 
     def __len__(self):
-        size = native_bt.value_array_get_size(self._ptr)
+        size = native_bt.value_array_get_length(self._ptr)
         assert size >= 0
         return size
 
This page took 0.026042 seconds and 4 git commands to generate.