X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fmessage.py;h=5039d923b59208c1b057f78256ec85083f99e96e;hb=f5567ea88d172767b34373bc6e402da8bfd85ef8;hp=95522736c490a980ea922a75db5cf9ded6bcd54d;hpb=dd26af5bf03f9b21a6ff8eaae0c993827a36cfcf;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/message.py b/src/bindings/python/bt2/bt2/message.py index 95522736..5039d923 100644 --- a/src/bindings/python/bt2/bt2/message.py +++ b/src/bindings/python/bt2/bt2/message.py @@ -22,7 +22,7 @@ class _MessageConst(object._SharedObject): def _check_has_default_clock_class(clock_class): if clock_class is None: raise ValueError( - 'cannot get default clock snapshot: stream class has no default clock class' + "cannot get default clock snapshot: stream class has no default clock class" ) @@ -212,7 +212,7 @@ class _DiscardedMessageConst(_MessageConst, _MessageWithDefaultClockSnapshot): def _check_has_default_clock_snapshots(self): if not self._has_default_clock_snapshots: raise ValueError( - 'cannot get default clock snapshot: such a message has no clock snapshots for this stream class' + "cannot get default clock snapshot: such a message has no clock snapshots for this stream class" ) @property @@ -233,6 +233,10 @@ class _DiscardedMessage(_DiscardedMessageConst, _Message): def _set_count(self, count): utils._check_uint64(count) + + if count == 0: + raise ValueError("discarded {} count is 0".format(self._item_name)) + self._set_count(self._ptr, count) _count = property(fget=_DiscardedMessageConst.count.fget, fset=_set_count) @@ -258,6 +262,7 @@ class _DiscardedEventsMessageConst(_DiscardedMessageConst): class _DiscardedEventsMessage(_DiscardedEventsMessageConst, _DiscardedMessage): _borrow_stream_ptr = staticmethod(native_bt.message_discarded_events_borrow_stream) _set_count = staticmethod(native_bt.message_discarded_events_set_count) + _item_name = "event" class _DiscardedPacketsMessageConst(_DiscardedMessageConst): @@ -280,6 +285,7 @@ class _DiscardedPacketsMessageConst(_DiscardedMessageConst): class _DiscardedPacketsMessage(_DiscardedPacketsMessageConst, _DiscardedMessage): _borrow_stream_ptr = staticmethod(native_bt.message_discarded_packets_borrow_stream) _set_count = staticmethod(native_bt.message_discarded_packets_set_count) + _item_name = "packet" _MESSAGE_TYPE_TO_CLS = {