From: Jérémie Galarneau Date: Mon, 18 Sep 2017 19:54:37 +0000 (-0400) Subject: Python babeltrace fix: allow None for event header and packet context setters X-Git-Tag: v2.0.0-pre4~12 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=f760c3f15b98c6057c2b7e60fb3cd37a7d421600 Python babeltrace fix: allow None for event header and packet context setters Signed-off-by: Jérémie Galarneau --- 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.")