#19688: add back and deprecate the internal HTMLParser.unescape() method.
This commit is contained in:
parent
32f0c7a67b
commit
f6de9eb2bb
|
@ -513,3 +513,10 @@ class HTMLParser(_markupbase.ParserBase):
|
||||||
def unknown_decl(self, data):
|
def unknown_decl(self, data):
|
||||||
if self.strict:
|
if self.strict:
|
||||||
self.error("unknown declaration: %r" % (data,))
|
self.error("unknown declaration: %r" % (data,))
|
||||||
|
|
||||||
|
# Internal -- helper to remove special character quoting
|
||||||
|
def unescape(self, s):
|
||||||
|
warnings.warn('The unescape method is deprecated and will be removed '
|
||||||
|
'in 3.5, use html.unescape() instead.',
|
||||||
|
DeprecationWarning, stacklevel=2)
|
||||||
|
return unescape(s)
|
||||||
|
|
|
@ -569,6 +569,13 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase):
|
||||||
for html, expected in data:
|
for html, expected in data:
|
||||||
self._run_check(html, expected)
|
self._run_check(html, expected)
|
||||||
|
|
||||||
|
def test_unescape_method(self):
|
||||||
|
from html import unescape
|
||||||
|
p = self.get_collector()
|
||||||
|
with self.assertWarns(DeprecationWarning):
|
||||||
|
s = '""""""&#bad;'
|
||||||
|
self.assertEqual(p.unescape(s), unescape(s))
|
||||||
|
|
||||||
def test_broken_comments(self):
|
def test_broken_comments(self):
|
||||||
html = ('<! not really a comment >'
|
html = ('<! not really a comment >'
|
||||||
'<! not a comment either -->'
|
'<! not a comment either -->'
|
||||||
|
|
Loading…
Reference in New Issue