bt2: rename CreationError to MemoryError, handle it in and out of Python bindings
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Jul 2019 06:08:59 +0000 (02:08 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 04:18:54 +0000 (00:18 -0400)
commit4acc866e829881299a13d0aa8e28b93807549975
tree0be1bb9adbdaece4b1c8fe645a8f8822546cb48d
parentce4923b0c7a2de36eba95725334d251e9aa08aad
bt2: rename CreationError to MemoryError, handle it in and out of Python bindings

Babeltrace API calls can explicitly return the MEMORY_ERROR status,
which is currently converted to a bt2.Error in Python.  If this
bt2.Error goes back to the native side of the bindings, is is converted
back to the ERROR status.  This is not ideal, as the status value should
stay MEMORY_ERROR when unwinding the stack.

Also, when creation functions fail (return NULL/None), we currently
raise a CreationError.  Those creation functions only return NULL/None
if there were memory issues, there is not other way they can
legitimately fail (otherwise they would return a status).  So it would
make sense for this to be reported as a MEMORY_ERROR.

To address these two issues, this patch:

- renames bt2.CreationError to bt2.MemoryError
- makes utils._handle_func_status raise a bt2.MemoryError when receiving
the MEMORY_ERROR status
- makes the native bindings return MEMORY_ERROR when catching a
bt2.MemoryError

Since there's no easy way to generate an actual MemoryError, I tested
this manually by hacking bt_graph_create to make it fail.

Change-Id: I4969e8ccd9618d8361fe45d0973df980bc9b7abd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1751
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
14 files changed:
src/bindings/python/bt2/bt2/__init__.py.in
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/field_class.py
src/bindings/python/bt2/bt2/graph.py
src/bindings/python/bt2/bt2/integer_range_set.py
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/native_bt_component_class.i
src/bindings/python/bt2/bt2/port.py
src/bindings/python/bt2/bt2/query_executor.py
src/bindings/python/bt2/bt2/stream.py
src/bindings/python/bt2/bt2/trace.py
src/bindings/python/bt2/bt2/trace_class.py
src/bindings/python/bt2/bt2/utils.py
src/bindings/python/bt2/bt2/value.py
This page took 0.026038 seconds and 4 git commands to generate.