@@ -29,10 +29,6 @@ def __init__(self):
29
29
raise RuntimeError (
30
30
"_markupbase.ParserBase must be subclassed" )
31
31
32
- def error (self , message ):
33
- raise NotImplementedError (
34
- "subclasses of ParserBase must override error()" )
35
-
36
32
def reset (self ):
37
33
self .lineno = 1
38
34
self .offset = 0
@@ -131,12 +127,11 @@ def parse_declaration(self, i):
131
127
# also in data attribute specifications of attlist declaration
132
128
# also link type declaration subsets in linktype declarations
133
129
# 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 )
135
131
else :
136
- self . error ("unexpected '[' char in declaration" )
132
+ raise AssertionError ("unexpected '[' char in declaration" )
137
133
else :
138
- self .error (
139
- "unexpected %r char in declaration" % rawdata [j ])
134
+ raise AssertionError ("unexpected %r char in declaration" % rawdata [j ])
140
135
if j < 0 :
141
136
return j
142
137
return - 1 # incomplete
@@ -156,7 +151,9 @@ def parse_marked_section(self, i, report=1):
156
151
# look for MS Office ]> ending
157
152
match = _msmarkedsectionclose .search (rawdata , i + 3 )
158
153
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
+ )
160
157
if not match :
161
158
return - 1
162
159
if report :
@@ -168,7 +165,7 @@ def parse_marked_section(self, i, report=1):
168
165
def parse_comment (self , i , report = 1 ):
169
166
rawdata = self .rawdata
170
167
if rawdata [i :i + 4 ] != '<!--' :
171
- self . error ('unexpected call to parse_comment()' )
168
+ raise AssertionError ('unexpected call to parse_comment()' )
172
169
match = _commentclose .search (rawdata , i + 4 )
173
170
if not match :
174
171
return - 1
@@ -192,7 +189,9 @@ def _parse_doctype_subset(self, i, declstartpos):
192
189
return - 1
193
190
if s != "<!" :
194
191
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
+ )
196
195
if (j + 2 ) == n :
197
196
# end of buffer; incomplete
198
197
return - 1
@@ -209,8 +208,9 @@ def _parse_doctype_subset(self, i, declstartpos):
209
208
return - 1
210
209
if name not in {"attlist" , "element" , "entity" , "notation" }:
211
210
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
+ )
214
214
# handle the individual names
215
215
meth = getattr (self , "_parse_doctype_" + name )
216
216
j = meth (j , declstartpos )
@@ -234,14 +234,14 @@ def _parse_doctype_subset(self, i, declstartpos):
234
234
if rawdata [j ] == ">" :
235
235
return j
236
236
self .updatepos (declstartpos , j )
237
- self . error ("unexpected char after internal subset" )
237
+ raise AssertionError ("unexpected char after internal subset" )
238
238
else :
239
239
return - 1
240
240
elif c .isspace ():
241
241
j = j + 1
242
242
else :
243
243
self .updatepos (declstartpos , j )
244
- self . error ("unexpected char %r in internal subset" % c )
244
+ raise AssertionError ("unexpected char %r in internal subset" % c )
245
245
# end of buffer reached
246
246
return - 1
247
247
@@ -387,8 +387,9 @@ def _scan_name(self, i, declstartpos):
387
387
return name .lower (), m .end ()
388
388
else :
389
389
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
+ )
392
393
393
394
# To be overridden -- handlers for unknown objects
394
395
def unknown_decl (self , data ):
0 commit comments