diff options
author | Fred Drake <fdrake@acm.org> | 2000-12-13 16:35:53 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-12-13 16:35:53 (GMT) |
commit | 5d1b5eaf55b5245d9a368811ab32cea6b080a1f9 (patch) | |
tree | ac9947a91eb10759f8995264e4036c52d877a8b8 /Lib/xml | |
parent | 64acf1db222a5045f1b3b467ab801e85f9f8955a (diff) | |
download | cpython-5d1b5eaf55b5245d9a368811ab32cea6b080a1f9.zip cpython-5d1b5eaf55b5245d9a368811ab32cea6b080a1f9.tar.gz cpython-5d1b5eaf55b5245d9a368811ab32cea6b080a1f9.tar.bz2 |
Add code to DOMException to ensure it cannot be instantiated directly,
since the API documentation will state specifically that the specializations
must be used by the DOM implementations.
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/dom/__init__.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/xml/dom/__init__.py b/Lib/xml/dom/__init__.py index abef398..b1211f4 100644 --- a/Lib/xml/dom/__init__.py +++ b/Lib/xml/dom/__init__.py @@ -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 |