Mercurial > p > roundup > code
changeset 5411:9c6d98bf79db
Python 3 preparation: update HTMLParser / htmlentitydefs imports.
Manual patch.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Wed, 25 Jul 2018 00:35:49 +0000 |
| parents | d0816d50ee8f |
| children | c75defc1c2f0 |
| files | roundup/dehtml.py |
| diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/dehtml.py Wed Jul 25 00:17:56 2018 +0000 +++ b/roundup/dehtml.py Wed Jul 25 00:35:49 2018 +0000 @@ -24,8 +24,14 @@ raise ImportError # use except ImportError: # use the fallback below if beautiful soup is not installed. - from HTMLParser import HTMLParser - from htmlentitydefs import name2codepoint + try: + # Python 3+. + from html.parser import HTMLParser + from html.entities import name2codepoint + except ImportError: + # Python 2. + from HTMLParser import HTMLParser + from htmlentitydefs import name2codepoint class DumbHTMLParser(HTMLParser): # class attribute
