Fix: bt2: do not assign an exception to a local variable
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 18 Sep 2017 19:52:12 +0000 (15:52 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 18 Sep 2017 19:58:15 +0000 (15:58 -0400)
commit34af27f540340851aaedea9fb2ed5a8f96af2e63
treec50abaf4d1d36db3cc916646639216cd6a2e9816
parentca715d4c6451b55350b6913eb6ea25c10814c5b4
Fix: bt2: do not assign an exception to a local variable

According to <https://docs.python.org/3/reference/compound_stmts.html#try>:

> Exceptions are cleared because with the traceback attached to them,
> they form a reference cycle with the stack frame, keeping all locals
> in that frame alive until the next garbage collection occurs.

According to <http://portingguide.readthedocs.io/en/latest/exceptions.html>:

> As discussed previously, in Python 3, all information about an
> exception, including the traceback, is contained in the exception
> object. Since the traceback holds references to the values of all
> local variables, storing an exception in a local variable usually
> forms a reference cycle, keeping all local variables allocated until
> the next garbage collection pass.

This reference cycle can make some tests fail because, with the
Babeltrace Python bindings, some operations are performed when a
Babeltrace native object is destroyed: this means the Python reference
count must be "stable" and as deterministic as possible so as to avoid
gc.collect() when using the bindings.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bindings/python/bt2/bt2/utils.py
This page took 0.024266 seconds and 4 git commands to generate.