mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 14:17:13 -05:00
don't error out when non-latin characters written to js console
(some?) macOS users have an ascii encoding, so we need to escape the non-ascii portions prior to writing
This commit is contained in:
parent
0008e6cb3f
commit
1f36a7112f
1 changed files with 4 additions and 2 deletions
|
|
@ -63,8 +63,10 @@ class AnkiWebPage(QWebEnginePage):
|
||||||
def javaScriptConsoleMessage(self, lvl, msg, line, srcID):
|
def javaScriptConsoleMessage(self, lvl, msg, line, srcID):
|
||||||
# not translated because console usually not visible,
|
# not translated because console usually not visible,
|
||||||
# and may only accept ascii text
|
# and may only accept ascii text
|
||||||
sys.stdout.write("JS error on line %(a)d: %(b)s" %
|
buf = "JS error on line %(a)d: %(b)s" % dict(a=line, b=msg+"\n")
|
||||||
dict(a=line, b=msg+"\n"))
|
# ensure we don't try to write characters the terminal can't handle
|
||||||
|
buf = buf.encode(sys.stdout.encoding, "backslashreplace").decode(sys.stdout.encoding)
|
||||||
|
sys.stdout.write(buf)
|
||||||
|
|
||||||
def acceptNavigationRequest(self, url, navType, isMainFrame):
|
def acceptNavigationRequest(self, url, navType, isMainFrame):
|
||||||
if not isMainFrame:
|
if not isMainFrame:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue