TypeError: decoding Unicode is not supported: "embedimage.py", line 72

Bug #1075321 reported by Aapo Rantalainen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Medium
Aapo Rantalainen

Bug Description

LANG: fi_FI.UTF-8
Python: 2.7.3
Inkscape: 0.48.3.1-1ubuntu1
Linux 3.2.0-27-generic #43-Ubuntu SMP Fri Jul 6 14:25:57 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

This is reproducible with large (non-releasable production) file. I'm still looking smallest test case to reproduce it.

Svg-file with linked png-images. Some image might have changed places (in filesystem), but everything is visible correctly.

Fields "sodipodi:absref" and/or "xlink:href" contain non-ascii characters (namely 'ö' and 'ä').

"Extensions" -> "Images" -> "Embed images...":

Traceback (most recent call last):
 File "embedimage.py", line 106, in <module>
   e.affect()
 File "/usr/local/share/inkscape/extensions/inkex.py", line 247, in affect
   self.effect()
 File "embedimage.py", line 38, in effect
   self.embedAll(self.document)
 File "embedimage.py", line 52, in embedAll
   self.embedImage(node)
 File "embedimage.py", line 72, in embedImage
   path=unicode(path, "utf-8")
TypeError: decoding Unicode is not supported

Workaround:
            path=''
            #path selection strategy:
            # 1. href if absolute
            # 2. realpath-ified href
            # 3. absref, only if the above does not point to a file
            if (href != None):
                path=os.path.realpath(href)
            if (not os.path.isfile(path)):
                if (absref != None):
                    path=absref

-path=unicode(path, "utf-8")
+try:
+ path=unicode(path, "utf-8")
+except TypeError:
+ path=path

Seems all path selection strategy is not returning in same format (unicode/utf8).

Related branches

summary: - ypeError: decoding Unicode is not supported: "embedimage.py", line 72,
- in embedImage
+ TypeError: decoding Unicode is not supported: "embedimage.py", line 72
su_v (suv-lp)
tags: added: encoding extensions-plugins
Revision history for this message
jazzynico (jazzynico) wrote :

Confirmed on Windows XP, Inkscape trunk revision 11871.

Changed in inkscape:
importance: Undecided → Medium
milestone: none → 0.49
status: New → Triaged
Revision history for this message
jazzynico (jazzynico) wrote :

Patch tested successfully on Windows.
Thanks for your help!

Changed in inkscape:
assignee: nobody → JazzyNico (jazzynico)
status: Triaged → In Progress
Revision history for this message
jazzynico (jazzynico) wrote :

Fix committed in the trunk, revision 11877.
Thanks!

Changed in inkscape:
assignee: JazzyNico (jazzynico) → Aapo Rantalainen (aapo-rantalainen)
status: In Progress → Fix Committed
tags: added: backport-proposed
Revision history for this message
jazzynico (jazzynico) wrote :

Backported to the branch, revision 9930.

Changed in inkscape:
milestone: 0.49 → 0.48.4
tags: removed: backport-proposed
Ted Gould (ted)
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.