From: Fred Drake Date: Mon, 24 Sep 2001 20:15:51 +0000 (+0000) Subject: Re-factor the SGMLParser class to use the new markupbase.ParserBase class. X-Git-Tag: v2.2.1c1~1646 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3bae3369cca83ee485ed3293e2ad4c53691ba1a;p=python Re-factor the SGMLParser class to use the new markupbase.ParserBase class. Use a new internal method, error(), consistently to raise parse errors; the new base class also uses this. Adjust the parse_comment() method to return the new offset into the buffer instead of the number of characters scanned; this was the only helper method that did it this way, so we have better consistency now. Required to share the new base class. This fixes SF bug #448482 and #453706. --- diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py index f2a302095b..2de7492c9a 100644 --- a/Lib/sgmllib.py +++ b/Lib/sgmllib.py @@ -9,6 +9,7 @@ # not supported at all. +import markupbase import re __all__ = ["SGMLParser"] @@ -27,24 +28,14 @@ charref = re.compile('&#([0-9]+)[^0-9]') starttagopen = re.compile('<[>a-zA-Z]') shorttagopen = re.compile('<[a-zA-Z][-.a-zA-Z0-9]*/') shorttag = re.compile('<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/') -piopen = re.compile('<\?') piclose = re.compile('>') -endtagopen = re.compile('a-zA-Z]') endbracket = re.compile('[<>]') -special = re.compile(']*>') -commentopen = re.compile('