python: mark _SharedObject._{get,put}_ref as abstract methods
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 8 Jun 2023 15:21:31 +0000 (11:21 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 8 Jun 2023 19:13:01 +0000 (15:13 -0400)
_get_ref and _put_ref must be implemented by any sub-class of
_SharedObject, marking them as abstract methods could help find
mistakes.

Change-Id: I0e161a0bbc1c432d9ed59279d3e4b1b6f6a26215
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10239
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/bindings/python/bt2/bt2/object.py

index fed138eced74e526699c074f53903df915d049a4..c1a23fdf353c8657503221834884f0ec675075e0 100644 (file)
@@ -3,6 +3,9 @@
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
 
+import abc
+
+
 class _BaseObject:
     # Ensure that the object always has _ptr set, even if it throws during
     # construction.
@@ -69,14 +72,14 @@ class _UniqueObject(_BaseObject):
 
 
 # Python object that owns a reference to a Babeltrace object.
-class _SharedObject(_BaseObject):
-
+class _SharedObject(_BaseObject, abc.ABC):
     # Get a new reference on ptr.
     #
     # This must be implemented by subclasses to work correctly with a pointer
     # of the native type they wrap.
 
     @staticmethod
+    @abc.abstractmethod
     def _get_ref(ptr):
         raise NotImplementedError
 
@@ -86,6 +89,7 @@ class _SharedObject(_BaseObject):
     # of the native type they wrap.
 
     @staticmethod
+    @abc.abstractmethod
     def _put_ref(ptr):
         raise NotImplementedError
 
This page took 0.025021 seconds and 4 git commands to generate.