diff --git a/changelog.d/1788.change.rst b/changelog.d/1788.change.rst new file mode 100644 index 0000000000..d8a49fd41d --- /dev/null +++ b/changelog.d/1788.change.rst @@ -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. diff --git a/setuptools/py33compat.py b/setuptools/py33compat.py index 87cf53983c..cb69443638 100644 --- a/setuptools/py33compat.py +++ b/setuptools/py33compat.py @@ -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