]> granicus.if.org Git - python/commitdiff
Add code to DOMException to ensure it cannot be instantiated directly,
authorFred Drake <fdrake@acm.org>
Wed, 13 Dec 2000 16:35:53 +0000 (16:35 +0000)
committerFred Drake <fdrake@acm.org>
Wed, 13 Dec 2000 16:35:53 +0000 (16:35 +0000)
since the API documentation will state specifically that the specializations
must be used by the DOM implementations.

Lib/xml/dom/__init__.py

index abef3983a6f024f0e4929ddf493d60fbe1d30b7b..b1211f4a2333f00136c6cb9ec3a6251a6f819710 100644 (file)
@@ -38,6 +38,7 @@ class Node:
     DOCUMENT_FRAGMENT_NODE      = 11
     NOTATION_NODE               = 12
 
+
 #ExceptionCode
 INDEX_SIZE_ERR                 = 1
 DOMSTRING_SIZE_ERR             = 2
@@ -55,11 +56,17 @@ INVALID_MODIFICATION_ERR       = 13
 NAMESPACE_ERR                  = 14
 INVALID_ACCESS_ERR             = 15
 
+
 class DOMException(Exception):
     """Abstract base class for DOM exceptions.
     Exceptions with specific codes are specializations of this class."""
     
-    pass
+    def __init__(self, *args, **kw):
+        if self.__class__ is DOMException:
+            raise RuntimeError(
+                "DOMException should not be instaniated directly")
+        apply(Exception.__init__, args, kw)
+
 
 class IndexSizeErr(DOMException):
     code = INDEX_SIZE_ERR