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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 7 Aug 2019 18:05:19 +0000 (14:05 -0400)
commit493428a0e391525646df54b91b63f295f565eb26
tree029573ce182fd9d0495491d33f133a0b8235289b
parent3b2be7085899350a58fe836dc5e1a9650ce369b2
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.026083 seconds and 4 git commands to generate.