#19688: add back and deprecate the internal HTMLParser.unescape() method.

This commit is contained in:
Ezio Melotti 2013-11-22 05:49:29 +02:00
parent 32f0c7a67b
commit f6de9eb2bb
2 changed files with 14 additions and 0 deletions

View File

@ -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)

View File

@ -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 = '"""&quot&#34&#x22&#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 -->'