Omit 'value' from is_set and reset field functions
[babeltrace.git] / bindings / python / bt2 / bt2 / fields.py
index afa02d5d9279b4c2f37b43e92a413ee72e4e7136..e3cbbef5a75ad5845107a2a9be6753a319f1d0bf 100644 (file)
@@ -78,11 +78,11 @@ class _Field(object._Object, metaclass=abc.ABCMeta):
 
     @property
     def is_set(self):
-        is_set = native_bt.ctf_field_value_is_set(self._ptr)
+        is_set = native_bt.ctf_field_is_set(self._ptr)
         return is_set > 0
 
     def reset(self):
-        ret = native_bt.ctf_field_reset_value(self._ptr)
+        ret = native_bt.ctf_field_reset(self._ptr)
         utils._handle_ret(ret, "cannot reset field object's value")
 
 
@@ -465,16 +465,9 @@ class _StructureField(_ContainerField, collections.abc.MutableMapping):
         return _create_from_ptr(ptr)
 
     def __setitem__(self, key, value):
-        # we can only set numbers and strings
-        if not isinstance(value, (numbers.Number, str)):
-            raise TypeError('expecting number object or string')
-
-        # raises if index is somehow invalid
+        # raises if key is somehow invalid
         field = self[key]
 
-        if not isinstance(field, (_NumericField, _StringField)):
-            raise TypeError('can only set the value of a number or string field')
-
         # the field's property does the appropriate conversion or raises
         # the appropriate exception
         field.value = value
@@ -654,12 +647,13 @@ class _SequenceField(_ArraySequenceField):
     _NAME = 'Sequence'
 
     def _count(self):
-        return self.length_field.value
+        return int(self.length_field)
 
     @property
     def length_field(self):
         field_ptr = native_bt.ctf_field_sequence_get_length(self._ptr)
-        utils._handle_ptr("cannot get sequence field object's length field")
+        if field_ptr is None:
+            return
         return _create_from_ptr(field_ptr)
 
     @length_field.setter
This page took 0.023902 seconds and 4 git commands to generate.