From f6de9eb2bb3c3c16694d582e3e1e2e9f56b97aab Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Fri, 22 Nov 2013 05:49:29 +0200 Subject: #19688: add back and deprecate the internal HTMLParser.unescape() method. --- Lib/html/parser.py | 7 +++++++ Lib/test/test_htmlparser.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Lib/html/parser.py b/Lib/html/parser.py index e793c37..a228e8e 100644 --- a/Lib/html/parser.py +++ b/Lib/html/parser.py @@ -513,3 +513,10 @@ class HTMLParser(_markupbase.ParserBase): def unknown_decl(self, data): if self.strict: 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) diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index a943d3a..509b3cd 100644 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -569,6 +569,13 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase): for html, expected in data: 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): html = ('' '' -- cgit v0.12