From: Philippe Proulx Date: Tue, 9 Dec 2014 00:02:13 +0000 (-0500) Subject: Python: CTFWriter: forbid Stream.__init__() X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=9f8e803f1cd78f83d8859c20ac94b72feba4345b;p=deliverable%2Fbabeltrace.git Python: CTFWriter: forbid Stream.__init__() In the CTF writer API, a Stream object may only be created using Writer.create_stream(), therefore rendering Stream.__init__() useless for the user, since the resulting object is not, and cannot, be associated with a Writer object. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/bindings/python/bt.py b/bindings/python/bt.py index 8105056a8..2bbe6b254 100644 --- a/bindings/python/bt.py +++ b/bindings/python/bt.py @@ -2620,18 +2620,8 @@ class CTFWriter: raise ValueError("Failed to set packet context type.") class Stream: - def __init__(self, stream_class): - """ - Create a stream of the given class. - """ - - if not isinstance(stream_class, CTFWriter.StreamClass): - raise TypeError("Invalid stream_class argument must be of type StreamClass.") - - self._s = nbt._bt_ctf_stream_create(stream_class._sc) - - if self._s is None: - raise ValueError("Stream creation failed.") + def __init__(self): + raise NotImplementedError("Stream cannot be instantiated; use Writer.create_stream()") def __del__(self): nbt._bt_ctf_stream_put(self._s)