You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTMLParser: undocumented not implemented method #76025
I am not sure whether this is a documentation omission, whether HTMLParser should provide an (empty?) implementation, or whether ParserBase should not raise a NotImplementedError (to make linters happy).
srittau commented on Oct 23, 2017
srittaumannequin
MannequinAuthor
More actions
The quoted code above should have used ParserBase:
classParserBase:
...
deferror(self, message):
raiseNotImplementedError(
"subclasses of ParserBase must override error()")
WilliamAyd commented on Oct 31, 2017
WilliamAydmannequin
Mannequin
More actions
Would we be open to setting the meta class of the ParserBase to ABCMeta and setting error as an abstract method? That at the very least would make the expectation clearer for subclasses.
I haven’t contributed to Python before but am open to this as a first attempt if the direction makes sense.
WilliamAyd commented on Oct 31, 2017
WilliamAydmannequin
Mannequin
More actions
And assuming that subclass requirement is intentional we could add an optional keyword argument to the HTMLParser that indicates what to do with errors, much like how encoding issues are handled within codecs. For backwards compatibility it can default to ignore, but fail and warn could be two alternate approaches that the error method could account for
_markupbase is a private and undocumented module and its only user is HTMLParser (sgmllib was removed from the stdlib in 2008) Since we already have removed HTMLParser.error(), I think we can just remove _markupbase.ParserBase.error() without a deprecation period.
After triaging bpo-34480, I realized that we can't simply remove the error() method because the _markupbase.ParserBase() class still uses it. I've just closed PR 8562.
@berker.peksag's last comment was he closed the PR on 23 August 2018. However, he reopened it on 6 January 2020 as @ezio.melotti mentioned that they are both needed.
The PR for this issue is waiting to be re-reviewed by Ezio.
Activity
srittau commentedon Oct 23, 2017
HTMLParser derives from _markupbase.ParserBase, which has the following method:
HTMLParser does not implement this method and the documentation for HTMLParser (https://docs.python.org/3.6/library/html.parser.html) does not mention that its sub-classes need to override it.
I am not sure whether this is a documentation omission, whether HTMLParser should provide an (empty?) implementation, or whether ParserBase should not raise a NotImplementedError (to make linters happy).
srittau commentedon Oct 23, 2017
The quoted code above should have used ParserBase:
WilliamAyd commentedon Oct 31, 2017
Would we be open to setting the meta class of the ParserBase to ABCMeta and setting error as an abstract method? That at the very least would make the expectation clearer for subclasses.
I haven’t contributed to Python before but am open to this as a first attempt if the direction makes sense.
WilliamAyd commentedon Oct 31, 2017
And assuming that subclass requirement is intentional we could add an optional keyword argument to the HTMLParser that indicates what to do with errors, much like how encoding issues are handled within codecs. For backwards compatibility it can default to ignore, but fail and warn could be two alternate approaches that the error method could account for
berkerpeksag commentedon Jul 30, 2018
HTMLParser.error() method was deprecated in Python 3.4 (88ebfb1#diff-1a7486df8279dbac7f20abd487947845R157) and removed in Python 3.5 (73a4359#diff-1a7486df8279dbac7f20abd487947845L171)
_markupbase is a private and undocumented module and its only user is HTMLParser (sgmllib was removed from the stdlib in 2008) Since we already have removed HTMLParser.error(), I think we can just remove _markupbase.ParserBase.error() without a deprecation period.
srittau commentedon Jul 30, 2018
Good call. Maybe it's actually time to retire _markupbase and merge ParserBase into HTMLParser.
berkerpeksag commentedon Aug 23, 2018
After triaging bpo-34480, I realized that we can't simply remove the error() method because the _markupbase.ParserBase() class still uses it. I've just closed PR 8562.
csabella commentedon Jun 14, 2020
@berker.peksag's last comment was he closed the PR on 23 August 2018. However, he reopened it on 6 January 2020 as @ezio.melotti mentioned that they are both needed.
The PR for this issue is waiting to be re-reviewed by Ezio.
berkerpeksag commentedon Jul 16, 2020
New changeset e34bbfd by Berker Peksag in branch 'master':
bpo-31844: Remove _markupbase.ParserBase.error() (GH-8562)
e34bbfd
berkerpeksag commentedon Jul 16, 2020
New changeset d4d127f by Berker Peksag in branch 'master':
bpo-31844: Move whatsnew note to 3.10.rst (GH-21504)
d4d127f
[fix] HTMLParser: undocumented not implemented method
[fix] HTMLParser: undocumented not implemented method
[fix] HTMLParser: undocumented not implemented method