bpo-31844: Remove _markupbase.ParserBase.error() (GH-8562)
This commit is contained in:
parent
936a660945
commit
e34bbfd61f
|
@ -887,6 +887,11 @@ Removed
|
||||||
:func:`asyncio.current_task` and :func:`asyncio.all_tasks` instead.
|
:func:`asyncio.current_task` and :func:`asyncio.all_tasks` instead.
|
||||||
(Contributed by Rémi Lapeyre in :issue:`40967`)
|
(Contributed by Rémi Lapeyre in :issue:`40967`)
|
||||||
|
|
||||||
|
* The ``ParserBase.error()`` method from the private and undocumented ``_markupbase``
|
||||||
|
module has been removed. :class:`html.parser.HTMLParser` is the only subclass of
|
||||||
|
``ParserBase`` and its ``error()`` implementation has already been removed in
|
||||||
|
Python 3.5.
|
||||||
|
(Contributed by Berker Peksag in :issue:`31844`.)
|
||||||
|
|
||||||
Porting to Python 3.9
|
Porting to Python 3.9
|
||||||
=====================
|
=====================
|
||||||
|
|
|
@ -29,10 +29,6 @@ class ParserBase:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"_markupbase.ParserBase must be subclassed")
|
"_markupbase.ParserBase must be subclassed")
|
||||||
|
|
||||||
def error(self, message):
|
|
||||||
raise NotImplementedError(
|
|
||||||
"subclasses of ParserBase must override error()")
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.lineno = 1
|
self.lineno = 1
|
||||||
self.offset = 0
|
self.offset = 0
|
||||||
|
@ -131,12 +127,11 @@ class ParserBase:
|
||||||
# also in data attribute specifications of attlist declaration
|
# also in data attribute specifications of attlist declaration
|
||||||
# also link type declaration subsets in linktype declarations
|
# also link type declaration subsets in linktype declarations
|
||||||
# also link attribute specification lists in link declarations
|
# also link attribute specification lists in link declarations
|
||||||
self.error("unsupported '[' char in %s declaration" % decltype)
|
raise AssertionError("unsupported '[' char in %s declaration" % decltype)
|
||||||
else:
|
else:
|
||||||
self.error("unexpected '[' char in declaration")
|
raise AssertionError("unexpected '[' char in declaration")
|
||||||
else:
|
else:
|
||||||
self.error(
|
raise AssertionError("unexpected %r char in declaration" % rawdata[j])
|
||||||
"unexpected %r char in declaration" % rawdata[j])
|
|
||||||
if j < 0:
|
if j < 0:
|
||||||
return j
|
return j
|
||||||
return -1 # incomplete
|
return -1 # incomplete
|
||||||
|
@ -156,7 +151,9 @@ class ParserBase:
|
||||||
# look for MS Office ]> ending
|
# look for MS Office ]> ending
|
||||||
match= _msmarkedsectionclose.search(rawdata, i+3)
|
match= _msmarkedsectionclose.search(rawdata, i+3)
|
||||||
else:
|
else:
|
||||||
self.error('unknown status keyword %r in marked section' % rawdata[i+3:j])
|
raise AssertionError(
|
||||||
|
'unknown status keyword %r in marked section' % rawdata[i+3:j]
|
||||||
|
)
|
||||||
if not match:
|
if not match:
|
||||||
return -1
|
return -1
|
||||||
if report:
|
if report:
|
||||||
|
@ -168,7 +165,7 @@ class ParserBase:
|
||||||
def parse_comment(self, i, report=1):
|
def parse_comment(self, i, report=1):
|
||||||
rawdata = self.rawdata
|
rawdata = self.rawdata
|
||||||
if rawdata[i:i+4] != '<!--':
|
if rawdata[i:i+4] != '<!--':
|
||||||
self.error('unexpected call to parse_comment()')
|
raise AssertionError('unexpected call to parse_comment()')
|
||||||
match = _commentclose.search(rawdata, i+4)
|
match = _commentclose.search(rawdata, i+4)
|
||||||
if not match:
|
if not match:
|
||||||
return -1
|
return -1
|
||||||
|
@ -192,7 +189,9 @@ class ParserBase:
|
||||||
return -1
|
return -1
|
||||||
if s != "<!":
|
if s != "<!":
|
||||||
self.updatepos(declstartpos, j + 1)
|
self.updatepos(declstartpos, j + 1)
|
||||||
self.error("unexpected char in internal subset (in %r)" % s)
|
raise AssertionError(
|
||||||
|
"unexpected char in internal subset (in %r)" % s
|
||||||
|
)
|
||||||
if (j + 2) == n:
|
if (j + 2) == n:
|
||||||
# end of buffer; incomplete
|
# end of buffer; incomplete
|
||||||
return -1
|
return -1
|
||||||
|
@ -209,8 +208,9 @@ class ParserBase:
|
||||||
return -1
|
return -1
|
||||||
if name not in {"attlist", "element", "entity", "notation"}:
|
if name not in {"attlist", "element", "entity", "notation"}:
|
||||||
self.updatepos(declstartpos, j + 2)
|
self.updatepos(declstartpos, j + 2)
|
||||||
self.error(
|
raise AssertionError(
|
||||||
"unknown declaration %r in internal subset" % name)
|
"unknown declaration %r in internal subset" % name
|
||||||
|
)
|
||||||
# handle the individual names
|
# handle the individual names
|
||||||
meth = getattr(self, "_parse_doctype_" + name)
|
meth = getattr(self, "_parse_doctype_" + name)
|
||||||
j = meth(j, declstartpos)
|
j = meth(j, declstartpos)
|
||||||
|
@ -234,14 +234,14 @@ class ParserBase:
|
||||||
if rawdata[j] == ">":
|
if rawdata[j] == ">":
|
||||||
return j
|
return j
|
||||||
self.updatepos(declstartpos, j)
|
self.updatepos(declstartpos, j)
|
||||||
self.error("unexpected char after internal subset")
|
raise AssertionError("unexpected char after internal subset")
|
||||||
else:
|
else:
|
||||||
return -1
|
return -1
|
||||||
elif c.isspace():
|
elif c.isspace():
|
||||||
j = j + 1
|
j = j + 1
|
||||||
else:
|
else:
|
||||||
self.updatepos(declstartpos, j)
|
self.updatepos(declstartpos, j)
|
||||||
self.error("unexpected char %r in internal subset" % c)
|
raise AssertionError("unexpected char %r in internal subset" % c)
|
||||||
# end of buffer reached
|
# end of buffer reached
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
@ -387,8 +387,9 @@ class ParserBase:
|
||||||
return name.lower(), m.end()
|
return name.lower(), m.end()
|
||||||
else:
|
else:
|
||||||
self.updatepos(declstartpos, i)
|
self.updatepos(declstartpos, i)
|
||||||
self.error("expected name token at %r"
|
raise AssertionError(
|
||||||
% rawdata[declstartpos:declstartpos+20])
|
"expected name token at %r" % rawdata[declstartpos:declstartpos+20]
|
||||||
|
)
|
||||||
|
|
||||||
# To be overridden -- handlers for unknown objects
|
# To be overridden -- handlers for unknown objects
|
||||||
def unknown_decl(self, data):
|
def unknown_decl(self, data):
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Remove ``ParserBase.error()`` method from the private and undocumented
|
||||||
|
``_markupbase`` module. :class:`html.parser.HTMLParser` is the only
|
||||||
|
subclass of ``ParserBase`` and its ``error()`` implementation was deprecated
|
||||||
|
in Python 3.4 and removed in Python 3.5.
|
Loading…
Reference in New Issue