Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html_parser causing "Deprecation Warning" in Python 3.8 #340

Open
Gujal00 opened this issue Nov 13, 2020 · 1 comment
Open

html_parser causing "Deprecation Warning" in Python 3.8 #340

Gujal00 opened this issue Nov 13, 2020 · 1 comment

Comments

@Gujal00
Copy link

Gujal00 commented Nov 13, 2020

This function has worked without any issues earlier, but is now raising a deprecation warning. Can this be fixed please.
This may be related to #307

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from six.moves import html_parser
>>> s = ''quote' is <b>bold</b>'
>>> h = html_parser.HTMLParser()
>>> h.unescape(s)
<stdin>:1: DeprecationWarning: The unescape method is deprecated and will be removed in 3.5, use html.unescape() instead.
"'quote' is <b>bold</b>"
>>> 

It still works fine in Python 2.7

Python 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:37:19) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from six.moves import html_parser
>>> s = '&#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;'
>>> h = html_parser.HTMLParser()
>>> h.unescape(s)
u"'quote' is <b>bold</b>"
>>> 
@pogman-code
Copy link

pogman-code commented Dec 8, 2020

With Python 3.9 this goes beyond deprecation as it is not supported at all anymore:

The unescape() method in the html.parser.HTMLParser class has been removed (it was deprecated since Python 3.4). html.unescape() should be used for converting character references to the corresponding unicode characters.

cf. https://docs.python.org/3/whatsnew/3.9.html

Python 3.9.0 (default, Oct  7 2020, 23:09:01) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from six.moves import html_parser
>>> s = '&#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;'
>>> h = html_parser.HTMLParser()
>>> h.unescape(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'HTMLParser' object has no attribute 'unescape'
>>> 

Edit: add example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants