Bug report
Hello,
I receive the error in the title from LGTM.com when subclassing the HTMLParser class. Should HTMLParser technically be calling: super().__init__(), or something similar, in its own initialiser? I know adding this call won't improve the functionality as the BaseParser initialiser does nothing of interest for subclasses, but I guess it would stop annoying errors like this.
Relevant code is here:
| classHTMLParser(_markupbase.ParserBase): |
| """Find tags and other markup and call handler functions. |
| |
| Usage: |
| p = HTMLParser() |
| p.feed(data) |
| ... |
| p.close() |
| |
| Start tags are handled by calling self.handle_starttag() or |
| self.handle_startendtag(); end tags by self.handle_endtag(). The |
| data between tags is passed from the parser to the derived class |
| by calling self.handle_data() with the data as argument (the data |
| may be split up in arbitrary chunks). If convert_charrefs is |
| True the character references are converted automatically to the |
| corresponding Unicode character (and self.handle_data() is no |
| longer split in chunks), otherwise they are passed by calling |
| self.handle_entityref() or self.handle_charref() with the string |
| containing respectively the named or numeric reference as the |
| argument. |
| """ |
| |
| CDATA_CONTENT_ELEMENTS= ("script", "style") |
| |
| def__init__(self, *, convert_charrefs=True): |
| """Initialize and reset this instance. |
| |
| If convert_charrefs is True (the default), all character references |
| are automatically converted to the corresponding Unicode characters. |
| """ |
| self.convert_charrefs=convert_charrefs |
| self.reset() |
And here:
| classParserBase: |
| """Parser base class which provides some common support methods used |
| by the SGML/HTML and XHTML parsers.""" |
| |
| def__init__(self): |
| ifself.__class__isParserBase: |
| raiseRuntimeError( |
| "_markupbase.ParserBase must be subclassed") |
Bug report
Hello,
I receive the error in the title from LGTM.com when subclassing the HTMLParser class. Should HTMLParser technically be calling:
super().__init__(), or something similar, in its own initialiser? I know adding this call won't improve the functionality as the BaseParser initialiser does nothing of interest for subclasses, but I guess it would stop annoying errors like this.Relevant code is here:
cpython/Lib/html/parser.py
Lines 62 to 93 in eb81c1a
And here:
cpython/Lib/_markupbase.py
Lines 23 to 30 in eb81c1a