[llvm.py] Make LLVMObject.__del__ work if called during __init__
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 10 Mar 2012 21:01:14 +0000 (21:01 +0000)
committerGregory Szorc <gregory.szorc@gmail.com>
Sat, 10 Mar 2012 21:01:14 +0000 (21:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152505 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/python/llvm/common.py

index 9911e69..0c5fcd0 100644 (file)
@@ -58,6 +58,9 @@ class LLVMObject(object):
         return self._as_parameter_
 
     def __del__(self):
+        if not hasattr(self, '_self_owned') or not hasattr(self, '_disposer'):
+            return
+
         if self._self_owned and self._disposer:
             self._disposer(self)