@@ -29,10 +29,6 @@ def __init__(self):
2929 raise RuntimeError (
3030 "_markupbase.ParserBase must be subclassed" )
3131
32- def error (self , message ):
33- raise NotImplementedError (
34- "subclasses of ParserBase must override error()" )
35-
3632 def reset (self ):
3733 self .lineno = 1
3834 self .offset = 0
@@ -131,12 +127,11 @@ def parse_declaration(self, i):
131127 # also in data attribute specifications of attlist declaration
132128 # also link type declaration subsets in linktype declarations
133129 # also link attribute specification lists in link declarations
134- self . error ("unsupported '[' char in %s declaration" % decltype )
130+ raise AssertionError ("unsupported '[' char in %s declaration" % decltype )
135131 else :
136- self . error ("unexpected '[' char in declaration" )
132+ raise AssertionError ("unexpected '[' char in declaration" )
137133 else :
138- self .error (
139- "unexpected %r char in declaration" % rawdata [j ])
134+ raise AssertionError ("unexpected %r char in declaration" % rawdata [j ])
140135 if j < 0 :
141136 return j
142137 return - 1 # incomplete
@@ -156,7 +151,9 @@ def parse_marked_section(self, i, report=1):
156151 # look for MS Office ]> ending
157152 match = _msmarkedsectionclose .search (rawdata , i + 3 )
158153 else :
159- self .error ('unknown status keyword %r in marked section' % rawdata [i + 3 :j ])
154+ raise AssertionError (
155+ 'unknown status keyword %r in marked section' % rawdata [i + 3 :j ]
156+ )
160157 if not match :
161158 return - 1
162159 if report :
@@ -168,7 +165,7 @@ def parse_marked_section(self, i, report=1):
168165 def parse_comment (self , i , report = 1 ):
169166 rawdata = self .rawdata
170167 if rawdata [i :i + 4 ] != '<!--' :
171- self . error ('unexpected call to parse_comment()' )
168+ raise AssertionError ('unexpected call to parse_comment()' )
172169 match = _commentclose .search (rawdata , i + 4 )
173170 if not match :
174171 return - 1
@@ -192,7 +189,9 @@ def _parse_doctype_subset(self, i, declstartpos):
192189 return - 1
193190 if s != "<!" :
194191 self .updatepos (declstartpos , j + 1 )
195- self .error ("unexpected char in internal subset (in %r)" % s )
192+ raise AssertionError (
193+ "unexpected char in internal subset (in %r)" % s
194+ )
196195 if (j + 2 ) == n :
197196 # end of buffer; incomplete
198197 return - 1
@@ -209,8 +208,9 @@ def _parse_doctype_subset(self, i, declstartpos):
209208 return - 1
210209 if name not in {"attlist" , "element" , "entity" , "notation" }:
211210 self .updatepos (declstartpos , j + 2 )
212- self .error (
213- "unknown declaration %r in internal subset" % name )
211+ raise AssertionError (
212+ "unknown declaration %r in internal subset" % name
213+ )
214214 # handle the individual names
215215 meth = getattr (self , "_parse_doctype_" + name )
216216 j = meth (j , declstartpos )
@@ -234,14 +234,14 @@ def _parse_doctype_subset(self, i, declstartpos):
234234 if rawdata [j ] == ">" :
235235 return j
236236 self .updatepos (declstartpos , j )
237- self . error ("unexpected char after internal subset" )
237+ raise AssertionError ("unexpected char after internal subset" )
238238 else :
239239 return - 1
240240 elif c .isspace ():
241241 j = j + 1
242242 else :
243243 self .updatepos (declstartpos , j )
244- self . error ("unexpected char %r in internal subset" % c )
244+ raise AssertionError ("unexpected char %r in internal subset" % c )
245245 # end of buffer reached
246246 return - 1
247247
@@ -387,8 +387,9 @@ def _scan_name(self, i, declstartpos):
387387 return name .lower (), m .end ()
388388 else :
389389 self .updatepos (declstartpos , i )
390- self .error ("expected name token at %r"
391- % rawdata [declstartpos :declstartpos + 20 ])
390+ raise AssertionError (
391+ "expected name token at %r" % rawdata [declstartpos :declstartpos + 20 ]
392+ )
392393
393394 # To be overridden -- handlers for unknown objects
394395 def unknown_decl (self , data ):
0 commit comments