X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bindings%2Fpython%2Fbabeltrace%2Fwriter.py;h=8ed18c6c9bb9adb5d936c0055a94671df432e130;hb=09ef660c8db235881eb2c8788770e8ca4f2df39e;hp=cd609afd730cf1c1e1120ff3c6b6abeed6a2b469;hpb=6b30e7f33df8f9f85e69fb7dc615f56de1ef082b;p=babeltrace.git diff --git a/bindings/python/babeltrace/writer.py b/bindings/python/babeltrace/writer.py index cd609afd..8ed18c6c 100644 --- a/bindings/python/babeltrace/writer.py +++ b/bindings/python/babeltrace/writer.py @@ -2141,11 +2141,23 @@ class Writer: Sets the CTF environment variable named *name* to value *value* (converted to a string). - :exc:`ValueError` is raised on error. + :exc:`ValueError` or `TypeError` is raised on error. """ - ret = nbt._bt_ctf_writer_add_environment_field(self._w, str(name), - str(value)) + if type(name) != str: + raise TypeError("Field name must be a string.") + + t = type(value) + + if t == str: + ret = nbt._bt_ctf_writer_add_environment_field(self._w, name, + value) + elif t == int: + ret = nbt._bt_ctf_writer_add_environment_field_int64(self._w, + name, + value) + else: + raise TypeError("Value type is not supported.") if ret < 0: raise ValueError("Could not add environment field to trace.")