image-occlusion-enhanced icon indicating copy to clipboard operation
image-occlusion-enhanced copied to clipboard

Python Exception on Add Cards with Arrowhead Line in Either Layer

Open MikeDacre opened this issue 5 years ago • 3 comments

Prerequisite checklist

  • [ x ] In case of a bug: Have you tried restarting Anki?
  • [ x ] Are you running the latest version of the add-on. Have you redownloaded the add-on from AnkiWeb to make sure?
  • [ x ] Did you check the add-on documentation (e.g. AnkiWeb description, Wiki if it exists) for known issues?
  • [ x ] Did you perform a cursory search through the existing issue reports?

What is the problem/feature you would like to see fixed/implemented?

This is a Bug Report

When a line element with an arrow head, any arrow head, has been added to either layer the following error messages appears when trying to add new cards:

Anki 2.1.5 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Windows 10
Flags: frz=True ao=True sv=1

Caught exception:
  File "aqt\webview.py", line 295, in handler
  File "C:\Users\Mike Dacre\AppData\Roaming\Anki2\addons21\1374772155\add.py", line 268, in <lambda>
    lambda val, choice=choice, close=close: self._onAddNotesButton(choice, close, val))
  File "C:\Users\Mike Dacre\AppData\Roaming\Anki2\addons21\1374772155\add.py", line 283, in _onAddNotesButton
    r = gen.generateNotes()
  File "C:\Users\Mike Dacre\AppData\Roaming\Anki2\addons21\1374772155\ngen.py", line 80, in generateNotes
    (svg_node, layer_node) = self._getMnodesAndSetIds()
  File "C:\Users\Mike Dacre\AppData\Roaming\Anki2\addons21\1374772155\ngen.py", line 190, in _getMnodesAndSetIds
    mask_doc = minidom.parseString(self.new_svg.encode('utf-8'))
<class 'AttributeError'>: 'NoneType' object has no attribute 'encode'

How can we reproduce the problem?

  1. Add a line element to the image with an arrow head
  2. Click either option to add cards

Expected behavior: Cards to add

Actual behavior: Error message as reported above

Reproducible?: Every time, even after complete upgrade and restart. Haven't tested on linux or Mac yet, will do so and add a comment here.

Version information

Anki

Version 2.1.5 Qt 5.9.2 PyQt 5.9

System

  • Operating system: Windows
  • Version: 10 Education, version 1803 build 17134.345

MikeDacre avatar Nov 04 '18 04:11 MikeDacre

I can confirm the same issue using Windows 10.

Debug info:
Anki 2.1.14 (7b93e985) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Windows 10
Flags: frz=True ao=True sv=1

Caught exception:
  File "aqt\webview.py", line 322, in handler
  File "C:\Users\Me\AppData\Roaming\Anki2\addons21\1374772155\add.py", line 268, in <lambda>
    lambda val, choice=choice, close=close: self._onAddNotesButton(choice, close, val))
  File "C:\Users\Me\AppData\Roaming\Anki2\addons21\1374772155\add.py", line 283, in _onAddNotesButton
    r = gen.generateNotes()
  File "C:\Users\Me\AppData\Roaming\Anki2\addons21\1374772155\ngen.py", line 80, in generateNotes
    (svg_node, layer_node) = self._getMnodesAndSetIds()
  File "C:\Users\Me\AppData\Roaming\Anki2\addons21\1374772155\ngen.py", line 190, in _getMnodesAndSetIds
    mask_doc = minidom.parseString(self.new_svg.encode('utf-8'))
<class 'AttributeError'>: 'NoneType' object has no attribute 'encode'

oldmankit avatar Sep 12 '19 10:09 oldmankit

The same error occured to me when I tried drawing anything with pencil tool. I had texts on seperate layer, and several masks on the mask layer. Windows 10, Anki 2.1.12


Caught exception:
  File "aqt\webview.py", line 317, in handler
  File "<dir>\1374772155\add.py", line 278, in <lambda>
    lambda val, choice=choice, close=close: self._onAddNotesButton(choice, close, val))
  File "<dir>\1374772155\add.py", line 293, in _onAddNotesButton
    r = gen.generateNotes()
  File "<dir>\1374772155\ngen.py", line 80, in generateNotes
    (svg_node, layer_node) = self._getMnodesAndSetIds()
  File "<dir>\1374772155\ngen.py", line 190, in _getMnodesAndSetIds
    mask_doc = minidom.parseString(self.new_svg.encode('utf-8'))
<class 'AttributeError'>: 'NoneType' object has no attribute 'encode'

BlueGreenMagick avatar Sep 21 '19 06:09 BlueGreenMagick

Thanks for the reports, guys. The issue here is two-fold:

  1. The current IOE alpha uses a highly outdated version of SVG-Edit under the hood which produces invalid SVG files when using particular tools (this issue was not present on 2.0 due to the older web engine used)
  2. The surrounding python code should probably handle cases like that more graciously, yielding a more informative error message

Fixing 2 is fairly simple. Fixing 1 will require upgrading to a newer SVG-Edit release, which is a bit more involved unfortunately.

I am planning on doing both for the 1.3 stable release, though.

glutanimate avatar Nov 23 '19 12:11 glutanimate