From e34bbfd61f405eef89e8aa50672b0b25022de320 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 16 Jul 2020 09:13:05 +0300 Subject: [PATCH] bpo-31844: Remove _markupbase.ParserBase.error() (GH-8562) --- Doc/whatsnew/3.9.rst | 5 +++ Lib/_markupbase.py | 35 ++++++++++--------- .../2018-07-30-12-48-17.bpo-31844.0_GKsD.rst | 4 +++ 3 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2018-07-30-12-48-17.bpo-31844.0_GKsD.rst diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index c2db9bc74cc..18cc5588bf2 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -887,6 +887,11 @@ Removed :func:`asyncio.current_task` and :func:`asyncio.all_tasks` instead. (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 ===================== diff --git a/Lib/_markupbase.py b/Lib/_markupbase.py index 2af5f1c23b6..3ad7e279960 100644 --- a/Lib/_markupbase.py +++ b/Lib/_markupbase.py @@ -29,10 +29,6 @@ class ParserBase: raise RuntimeError( "_markupbase.ParserBase must be subclassed") - def error(self, message): - raise NotImplementedError( - "subclasses of ParserBase must override error()") - def reset(self): self.lineno = 1 self.offset = 0 @@ -131,12 +127,11 @@ class ParserBase: # also in data attribute specifications of attlist declaration # also link type declaration subsets in linktype 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: - self.error("unexpected '[' char in declaration") + raise AssertionError("unexpected '[' char in declaration") else: - self.error( - "unexpected %r char in declaration" % rawdata[j]) + raise AssertionError("unexpected %r char in declaration" % rawdata[j]) if j < 0: return j return -1 # incomplete @@ -156,7 +151,9 @@ class ParserBase: # look for MS Office ]> ending match= _msmarkedsectionclose.search(rawdata, i+3) 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: return -1 if report: @@ -168,7 +165,7 @@ class ParserBase: def parse_comment(self, i, report=1): rawdata = self.rawdata if rawdata[i:i+4] != '