Skip to content

Save as .sif - type error between svg.get and get_dimension

This is also being tracked in nikitakit/svg2sif#6 and synfig/synfig#1519.

Steps to reproduce:

  1. Open this example svg with Inkscape
  2. File → Save as → select Synfig extension .sif and Save

What happened?

Inkscape returns an error, here is the traceback:

Traceback (most recent call last):
  File "synfig_output.py", line 1336, in <module>
    SynfigExport().run()
  File "/usr/share/inkscape/extensions/inkex/base.py", line 123, in run
    self.save_raw(self.effect())
  File "synfig_output.py", line 1057, in effect
    width = get_dimension(svg.get("width", 1024))
  File "/usr/share/inkscape/extensions/synfig_prepare.py", line 435, in get_dimension
    elif s[-1] == "%":
TypeError: 'int' object is not subscriptable

It appears the call to svg.get("width", 1024)) is returning an int, but the surrounding function, get_dimension(), expects a string or a float.

What should have happened?

Save the .sif file as expected.

In my testing, just wrapping svg.get() calls with str() seemed to do the trick, although I unfortunately ran into #198 (closed) immediately after fixing this for myself. Regardless, if svg.get() can return any datatype, and this extension assumed only strings were coming back, it might be worth a more thorough look through the codebase to make sure svg.get() is being used properly.

Inkscape Version and Operating System:

  • Inkscape Version: 1.0-5 (inkscape@4035a4fb, 2020-05-01)
  • Operating System: Manjaro Linux x86_64
  • Kernel: 5.4.52-1-MANJARO
  • Operating System version: 10 64-bit
Edited by MyriaCore
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information