summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2004-09-09 02:24:13 (GMT)
committerFred Drake <fdrake@acm.org>2004-09-09 02:24:13 (GMT)
commit583359ed2e9696bcb1ca0223a4763074c19756d6 (patch)
tree03caa35fe0a83a2b590682c17aaa41507b3f643b
parent58ae830fd05e7cf12364ba187c6f5f5f1c5cfadd (diff)
downloadcpython-583359ed2e9696bcb1ca0223a4763074c19756d6.zip
cpython-583359ed2e9696bcb1ca0223a4763074c19756d6.tar.gz
cpython-583359ed2e9696bcb1ca0223a4763074c19756d6.tar.bz2
clean up the API a little; exceptions are defined by this module
(needs documentation)
-rw-r--r--Lib/htmllib.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/Lib/htmllib.py b/Lib/htmllib.py
index 94492a6..24a2e2f 100644
--- a/Lib/htmllib.py
+++ b/Lib/htmllib.py
@@ -4,13 +4,18 @@ See the HTML 2.0 specification:
http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
"""
+import sgmllib
-from sgmllib import SGMLParser
from formatter import AS_IS
-__all__ = ["HTMLParser"]
+__all__ = ["HTMLParser", "HTMLParseError"]
-class HTMLParser(SGMLParser):
+
+class HTMLParseError(sgmllib.SGMLParseError):
+ """Error raised when an HTML document can't be parsed."""
+
+
+class HTMLParser(sgmllib.SGMLParser):
"""This is the basic HTML parser class.
It supports all entity names required by the XHTML 1.0 Recommendation.
@@ -28,11 +33,14 @@ class HTMLParser(SGMLParser):
the parser.
"""
- SGMLParser.__init__(self, verbose)
+ sgmllib.SGMLParser.__init__(self, verbose)
self.formatter = formatter
+ def error(self, message):
+ raise HTMLParseError(message)
+
def reset(self):
- SGMLParser.reset(self)
+ sgmllib.SGMLParser.reset(self)
self.savedata = None
self.isindex = 0
self.title = None