]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_extras.py
Made metal theme a little faster.
[wxWidgets.git] / wxPython / src / _extras.py
index 866ab98cf77522bdcbc559111cd06925fa73e42f..d90b2a39f94d3e0667b40c14fda9409b8f67b740 100644 (file)
@@ -649,6 +649,8 @@ def wxPyTypeCast(obj, typeStr):
 
 #----------------------------------------------------------------------------
 
+class wxPyDeadObjectError(AttributeError):
+    pass
 
 class _wxPyDeadObject:
     """
@@ -656,15 +658,21 @@ class _wxPyDeadObject:
     changed to this class when the C++ object is deleted.  This should help
     prevent crashes due to referencing a bogus C++ pointer.
     """
+    reprStr = "wxPython wrapper for DELETED %s object! (The C++ object no longer exists.)"
+    attrStr = "The C++ %s object has been deleted, attribute access no longer allowed."
+
     def __repr__( self ):
         if not hasattr(self, "_name"):
             self._name = "[unknown]"
-        return 'wxPython wrapper for deleted %s object!!! Programming logic error' % self._name
+        return self.reprStr % self._name
 
     def __getattr__( self, *args ):
         if not hasattr(self, "_name"):
             self._name = "[unknown]"
-        raise ValueError, 'Attempt to access attribute of a deleted %s object' % self._name
+        raise wxPyDeadObjectError( self.attrStr % self._name )
+
+    def __nonzero__(self):
+        return 0
 
 
 #----------------------------------------------------------------------