remi
remi copied to clipboard
2 bugs remain for python 3.10
- https://github.com/rawpython/remi/pull/330
as the post says, maybe we can change
remi.gui.py: from
import cgi
escape = cgi.escape
to
try:
import cgi
escape = cgi.escape
except:
import html
escape = html.escape
- https://github.com/rawpython/remi/issues/412
now we should change
remi.gui.py: from
except ImportError:
# Python 3
try:
from html.parser import HTMLParser
h = HTMLParser()
unescape = h.unescape
except ImportError:
# Python 3.4+
import html
unescape = html.unescape
which says
File "e:\prg\py\winpython\python-3.10.9.amd64\lib\site-packages\remi-1.2.2-py3.10.egg\remi\gui.py", line 30, in <module>
from HTMLParser import HTMLParser
ModuleNotFoundError: No module named 'HTMLParser'
to
except ImportError:
# Python 3
try:
from html.parser import HTMLParser
h = HTMLParser()
unescape = h.unescape
except:
# Python 3.4+
import html
unescape = html.unescape
There are very few cases where except: is a good solution, and even less of those where you are not going to re-raise the exception afterwards. Also, I suggest to reverse the order of trials; first check for the newer solution, then fall back to the old, rather than vice-versa. For the second problem, you could do, for example:
except ImportError:
# Python 3
try:
# Python 3.4+
import html
unescape = html.unescape
except (AttributeError, ImportError):
from html.parser import HTMLParser
h = HTMLParser()
unescape = h.unescape