bt2: remove utils._handle_ptr
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Jul 2019 03:37:03 +0000 (23:37 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 04:18:54 +0000 (00:18 -0400)
commit5ae9f1bf3332a2dff16e6e811b982f0b5602dc47
treea7ec8b8b0e3c2defef4b4583dba48380a1e2ae7d
parentcacd0713f087e93cdb4c58d5d303ff473df8803e
bt2: remove utils._handle_ptr

A future patch will want to get rid of spots that raise bt2.Error, which
are not in direct response to a failed Babeltrace API call.  The
utils._handle_ptr is one such spot.  It turns out that the usages of
utils._handle_ptr are not useful anymore, because they check
situations that can either never happen, or are check by pre-condition
checks.

In connection.py, it's not possible anymore for
bt_connection_borrow_downstream_port_const or
bt_connection_borrow_upstream_port_const to return NULL/None, as
connections always have both ports set.

In field.py, the call in _create_field_from_ptr after
bt_field_borrow_class_const can be removed, as it's impossible for this
function to legitimately return NULL/None.

The call in _VariantField.selected_option is unnecessary, as it is after
a pre-condition check that the variant's selected option is non-NULL.
If we want to make Python bindings user-friendly (avoid hitting
pre-condition checks), we check before the call if the variant has a
currently selection option, and raise ValueError otherwise.  However,
there does not seem to be an API for that at the moment.

Change-Id: I585e57030d58256cbf51161e75394503c281addf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1743
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/bindings/python/bt2/bt2/connection.py
src/bindings/python/bt2/bt2/field.py
src/bindings/python/bt2/bt2/utils.py
This page took 0.026452 seconds and 4 git commands to generate.