Content-Length: 307569 | pFad | http://github.com/python/cpython/commit/f6de9eb2bb3c3c16694d582e3e1e2e9f56b97aab

D1 #19688: add back and deprecate the internal HTMLParser.unescape() met… · python/cpython@f6de9eb · GitHub
Skip to content

Commit f6de9eb

Browse files
committed
#19688: add back and deprecate the internal HTMLParser.unescape() method.
1 parent 32f0c7a commit f6de9eb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Lib/html/parser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,3 +513,10 @@ def handle_pi(self, data):
513513
def unknown_decl(self, data):
514514
if self.strict:
515515
self.error("unknown declaration: %r" % (data,))
516+
517+
# Internal -- helper to remove special character quoting
518+
def unescape(self, s):
519+
warnings.warn('The unescape method is deprecated and will be removed '
520+
'in 3.5, use html.unescape() instead.',
521+
DeprecationWarning, stacklevel=2)
522+
return unescape(s)

Lib/test/test_htmlparser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,13 @@ def test_EOF_in_charref(self):
569569
for html, expected in data:
570570
self._run_check(html, expected)
571571

572+
def test_unescape_method(self):
573+
from html import unescape
574+
p = self.get_collector()
575+
with self.assertWarns(DeprecationWarning):
576+
s = '"""&quot&#34&#x22&#bad;'
577+
self.assertEqual(p.unescape(s), unescape(s))
578+
572579
def test_broken_comments(self):
573580
html = ('<! not really a comment >'
574581
'<! not a comment either -->'

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/commit/f6de9eb2bb3c3c16694d582e3e1e2e9f56b97aab

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy