Package: anki
Version: 2.1.15+dfsg-2
Severity: normal
Tags: patch

Hello,

since the update to python3.9 Anki fails with the following
exception when reviewing more complex HTML templates:

    <class 'AttributeError'>: 'HTMLParser' object has no attribute 'unescape'

The following patch fixes this issue for me:

--- /usr/share/anki/aqt/reviewer.py.orig        2019-08-27 07:24:40.000000000 
+0200
+++ /usr/share/anki/aqt/reviewer.py     2020-11-21 16:49:53.517798570 +0100
@@ -353,13 +353,12 @@
         buf = buf.replace("<hr id=answer>", "")
         hadHR = len(buf) != origSize
         # munge correct value
-        parser = html.parser.HTMLParser()
         cor = self.mw.col.media.strip(self.typeCorrect)
         cor = re.sub("(\n|<br ?/?>|</?div>)+", " ", cor)
         cor = stripHTML(cor)
         # ensure we don't chomp multiple whitespace
         cor = cor.replace(" ", "&nbsp;")
-        cor = parser.unescape(cor)
+        cor = html.parser.unescape(cor)
         cor = cor.replace("\xa0", " ")
         cor = cor.strip()
         given = self.typedAnswer

It looks like unescape() was never intended to be exposed via the
HTMLParser() object. But since Python 3.4 html.parser provides it
directly.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

Attachment: signature.asc
Description: PGP signature

Reply via email to