]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#19688: add back and deprecate the internal HTMLParser.unescape() method.
authorEzio Melotti <ezio.melotti@gmail.com>
Fri, 22 Nov 2013 03:49:29 +0000 (05:49 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Fri, 22 Nov 2013 03:49:29 +0000 (05:49 +0200)
Lib/html/parser.py
Lib/test/test_htmlparser.py

index e793c37cd8009190c85d8b8a6bf122f6adcca8bb..a228e8ed370f218904932dcd26297d42780e4a14 100644 (file)
@@ -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)
index a943d3a45304a84804d4ef680fee18120074178b..509b3cdcbe1d5d50a31fdf057c5e94dea45e0b80 100644 (file)
@@ -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 = '&quot;&#34;&#x22;&quot&#34&#x22&#bad;'
+            self.assertEqual(p.unescape(s), unescape(s))
+
     def test_broken_comments(self):
         html = ('<! not really a comment >'
                 '<! not a comment either -->'