From f760c3f15b98c6057c2b7e60fb3cd37a7d421600 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 18 Sep 2017 15:54:37 -0400 Subject: [PATCH] Python babeltrace fix: allow None for event header and packet context setters MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- bindings/python/babeltrace/babeltrace/writer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bindings/python/babeltrace/babeltrace/writer.py b/bindings/python/babeltrace/babeltrace/writer.py index 12e04022..6ee53dc6 100644 --- a/bindings/python/babeltrace/babeltrace/writer.py +++ b/bindings/python/babeltrace/babeltrace/writer.py @@ -1745,11 +1745,13 @@ class StreamClass: @packet_context_type.setter def packet_context_type(self, field_type): - if not isinstance(field_type, StructureFieldDeclaration): + if field_type is not None and not isinstance(field_type, + StructureFieldDeclaration): raise TypeError("field_type argument must be of type StructureFieldDeclaration.") + bt2_field_type = None if field_type is None else field_type._field_type try: - self._stream_class.packet_context_field_type = field_type._field_type + self._stream_class.packet_context_field_type = bt2_field_type except: raise ValueError("Failed to set packet context type.") @@ -1779,11 +1781,13 @@ class StreamClass: @event_context_type.setter def event_context_type(self, field_type): - if not isinstance(field_type, StructureFieldDeclaration): + if field_type is not None and not isinstance(field_type, + StructureFieldDeclaration): raise TypeError("field_type argument must be of type StructureFieldDeclaration.") + bt2_field_type = None if field_type is None else field_type._field_type try: - self._stream_class.event_context_field_type = field_type._field_type + self._stream_class.event_context_field_type = bt2_field_type except: raise ValueError("Failed to set event context type.") -- 2.34.1