Python babeltrace fix: allow None for event header and packet context setters
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 18 Sep 2017 19:54:37 +0000 (15:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 18 Sep 2017 21:17:49 +0000 (17:17 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bindings/python/babeltrace/babeltrace/writer.py

index 12e040229c00bc8a20dc9db2bd845ae2b07db8d7..6ee53dc65569fe4dc8c6dad044da0d08d21d92f6 100644 (file)
@@ -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.")
 
This page took 0.025545 seconds and 4 git commands to generate.