Skip to content

Commit 1ec8a76

Browse files
committed
Python 3 preparation: update HTMLParser / htmlentitydefs imports.
Manual patch.
1 parent 1761410 commit 1ec8a76

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

roundup/dehtml.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ def html2text(html):
2424
raise ImportError # use
2525
except ImportError:
2626
# use the fallback below if beautiful soup is not installed.
27-
from HTMLParser import HTMLParser
28-
from htmlentitydefs import name2codepoint
27+
try:
28+
# Python 3+.
29+
from html.parser import HTMLParser
30+
from html.entities import name2codepoint
31+
except ImportError:
32+
# Python 2.
33+
from HTMLParser import HTMLParser
34+
from htmlentitydefs import name2codepoint
2935

3036
class DumbHTMLParser(HTMLParser):
3137
# class attribute

0 commit comments

Comments
 (0)