Saving as GIMP palette failes with AttributeError

Bug #256093 reported by Julian Kniephoff
0
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Low
Unassigned

Bug Description

Saving a drawing as GIMP palette (*.gpl) (File -> Save As -> GIMP Palette (*.gpl) fails here with the following message:

Traceback (most recent call last):
  File "/usr/local/share/inkscape/extensions/export_gimp_palette.py", line 46, in <module>
    walk(dom)
  File "/usr/local/share/inkscape/extensions/export_gimp_palette.py", line 20, in walk
    checkStyle(node)
  File "/usr/local/share/inkscape/extensions/export_gimp_palette.py", line 28, in checkStyle
    if node.hasAttributes():
AttributeError: Document instance has no attribute 'hasAttributes'

The file actually is created but empty.

I am on (K)Ubuntu 8.04.1 (x86) but use the current SVN version of Inkscape (rev. 19610, which I installed just today (because of another bug in Ubuntus Inkscape version ;). My python-xml version (the package, that contains minidom in Ubuntu -- which is used by the export_gimp_palette.py script) is 0.8.4-10ubuntu2

I have attached a patch for export_gimp_palette.py which naively fixes this problem by just catching and ignoring all AttributeErrors in the affected code. This is kind of "inaccurate" because other attributes may also not be there and cannot just be ignored. The alternative to this approach would be to check the node type in the checkStyle or walk method: Text nodes have no hasAttributes for me as does the Document node.
At the moment however this inaccuracy does not seem to be an issue. I would however rewrite the patch if requested.
The good thing of the former approach is, that it is a bit more pythonic (doing what you want and handle the consequences instead of passively prechecking everything ;).

The palette export seems to work for others and if this error is my fault or so, then please just ignore this report.
The patch does not do any harm, though ;).

Revision history for this message
Julian Kniephoff (jules-k) wrote :
Revision history for this message
Pablo Trabajos (pajarico) wrote :

Thanks for the testing and the patch.
The export_gimp_palette.py extension we have now is different from both rev 19610 and your diff. Seems like it was fixed already, could you please try a recent release? (at this moment it's 0.47-pre1).

Changed in inkscape:
status: New → Incomplete
Revision history for this message
Julian Kniephoff (jules-k) wrote :

You're right; I just tested inkscape-0.47pre1 and it correctly exports as GIMP Palette without any errors.

Sorry, but I'm still pretty unexperienced in working with launchpad: What am I supposed to do with this bug report now?

Revision history for this message
jazzynico (jazzynico) wrote :

Closed Fix committed.
Thanks!

Changed in inkscape:
importance: Undecided → Low
milestone: none → 0.47
status: Incomplete → Fix Committed
ScislaC (scislac)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.