X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fmessage_iterator.py;h=b07e2450afc97b46f7b5e46c1198d6f07aeb2853;hb=d79a835343447b4e7f62af721cfb2a05fa9f450a;hp=bde3afa054a11a1ca4265fae050fd7f9df0ba8e6;hpb=e74dbb3322844980db73bcd994891c48c68be862;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/message_iterator.py b/src/bindings/python/bt2/bt2/message_iterator.py index bde3afa0..b07e2450 100644 --- a/src/bindings/python/bt2/bt2/message_iterator.py +++ b/src/bindings/python/bt2/bt2/message_iterator.py @@ -131,9 +131,11 @@ class _UserMessageIterator(_MessageIterator): utils._check_type(msg, bt2.message._Message) - # Release the reference to the native part. - ptr = msg._release() - return int(ptr) + # The reference we return will be given to the message array. + # However, the `msg` Python object may stay alive, if the user has kept + # a reference to it. Acquire a new reference to account for that. + msg._get_ref(msg._ptr) + return int(msg._ptr) def _create_event_message(self, event_class, packet, default_clock_snapshot=None): utils._check_type(event_class, bt2.event_class._EventClass)