Fix reprounzip-qt on Python 3
from __future__ import division, print_function, unicode_literals
-import cgi
import locale
import logging
from qtpy import QtCore, QtWidgets
import sys
+if sys.version >= (3,):
+ from html import escape
+else:
+ from cgi import escape
+
+
logger = logging.getLogger('reprounzip_qt')
@@ -82,7 +87,7 @@ body {
</style>
''')
self.text.append('<span style="color: blue;">%s</span>' %
- cgi.escape(' '.join(cmdline)))
+ escape(' '.join(cmdline)))
def _enter(self):
cmd = self.input.text()
@@ -93,13 +98,13 @@ body {
out = self.process.readAllStandardOutput()
out = bytes(out).decode(locale.getpreferredencoding() or 'UTF-8',
'replace')
- self.text.append('<span>%s</span>' % cgi.escape(out))
+ self.text.append('<span>%s</span>' % escape(out))
def _read_stderr(self):
out = self.process.readAllStandardError()
out = bytes(out).decode(locale.getpreferredencoding() or 'UTF-8',
'replace')
- self.text.append('<span class="err">%s</span>' % cgi.escape(out))
+ self.text.append('<span class="err">%s</span>' % escape(out))
def _finished(self, code, status):
good = False
