bt2: move __version__ to version.py.in
[babeltrace.git] / src / bindings / python / bt2 / bt2 / field.py
index a98357f1e5099c07d989284bb582c125c7cdcdad..c8e292b195ff65f99b22ee21e43bcd52cfc94575 100644 (file)
@@ -21,7 +21,7 @@
 # THE SOFTWARE.
 
 from bt2 import native_bt, object, utils
-import bt2.field_class
+from bt2 import field_class as bt2_field_class
 import collections.abc
 import functools
 import numbers
@@ -31,7 +31,6 @@ import bt2
 
 def _create_field_from_ptr(ptr, owner_ptr, owner_get_ref, owner_put_ref):
     field_class_ptr = native_bt.field_borrow_class_const(ptr)
-    utils._handle_ptr(field_class_ptr, "cannot get field object's class")
     typeid = native_bt.field_class_get_type(field_class_ptr)
     field = _TYPE_ID_TO_OBJ[typeid]._create_from_ptr_and_get_ref(
         ptr, owner_ptr, owner_get_ref, owner_put_ref
@@ -60,7 +59,7 @@ class _Field(object._UniqueObject):
     def field_class(self):
         field_class_ptr = native_bt.field_borrow_class_const(self._ptr)
         assert field_class_ptr is not None
-        return bt2.field_class._create_field_class_from_ptr_and_get_ref(field_class_ptr)
+        return bt2_field_class._create_field_class_from_ptr_and_get_ref(field_class_ptr)
 
     def _repr(self):
         raise NotImplementedError
@@ -465,8 +464,10 @@ class _VariantField(_ContainerField, _Field):
 
     @property
     def selected_option(self):
+        # TODO: Is there a way to check if the variant field has a selected_option,
+        # so we can raise an exception instead of hitting a pre-condition check?
+        # If there is something, that check should be added to selected_option_index too.
         field_ptr = native_bt.field_variant_borrow_selected_option_field(self._ptr)
-        utils._handle_ptr(field_ptr, "cannot get variant field's selected option")
 
         return _create_field_from_ptr(
             field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
This page took 0.024179 seconds and 4 git commands to generate.