Update Python bindings and tests to match the latest API
[babeltrace.git] / bindings / python / bt2 / object.py
index ef574e1220778660db39401521f07b3bf4b80cfb..774027cbdc6685105b72bb1154d3992eb385fe5d 100644 (file)
@@ -1,6 +1,6 @@
 # The MIT License (MIT)
 #
-# Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+# Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -44,6 +44,7 @@ class _Object:
     def __del__(self):
         ptr = getattr(self, '_ptr', None)
         native_bt.put(ptr)
+        self._ptr = None
 
     def __repr__(self):
         return '<{}.{} object @ {}>'.format(self.__class__.__module__,
@@ -51,6 +52,14 @@ class _Object:
                                             hex(self.addr))
 
 
+class _PrivateObject:
+    def __del__(self):
+        pub_ptr = getattr(self, '_pub_ptr', None)
+        native_bt.put(pub_ptr)
+        self._pub_ptr = None
+        super().__del__()
+
+
 class _Freezable(metaclass=abc.ABCMeta):
     @property
     def is_frozen(self):
This page took 0.024206 seconds and 4 git commands to generate.