Skip to content

Commit

Permalink
Stop using deprecated HTMLParser.unescape
Browse files Browse the repository at this point in the history
HTMLParser.unescape is accessed even when unused - this will cause an
exception when `HTMLParser.unescape` is removed in Python 3.9.
  • Loading branch information
methane authored and pganssle committed Jun 19, 2019
1 parent 8aeff6b commit 53b8db3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/1788.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed compatibility fallback logic for ``html.unescape`` to avoid accessing ``HTMLParser.unescape`` when not necessary. ``HTMLParser.unescape`` is deprecated and will be removed in Python 3.9.
6 changes: 5 additions & 1 deletion setuptools/py33compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ def __iter__(self):
Bytecode = getattr(dis, 'Bytecode', Bytecode_compat)


unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
unescape = getattr(html, 'unescape', None)
if unescape is None:
# HTMLParser.unescape is deprecated since Python 3.4, and will be removed
# from 3.9.
unescape = html_parser.HTMLParser().unescape

0 comments on commit 53b8db3

Please sign in to comment.