2012-03-14, 00:13
Hi,
while reading the forum I found this thread: http://forum.xbmc.org/showthread.php?tid...pid1039311
I did a few tests and can confirm that it is very easy to reproduce and effects most addons - in a not so unrealistic scenario:
- You just need an unicode letter in the xbmc path (which contains the windows-username on windows7). Not sure on the other OS's...
You can easy reproduce this (or test your addons) with starting xbmc in portable mode (add "-p" to you xbmc start shortcut) from a xbmc folder which contains an unicode letter, "ä" or "é" for example.
So just download xbmc again, install it to "C:\folder-with-unicode-ä-é\xbmc" and start "C:\folder-with-unicode-ä-é\xbmc\xbmc.exe -p".
You can also test it with starting xbmc with a local windows username which contans unicode-letters.
I cloned the eden plugins repo and got ~200 line matches without a real unicode decoding:
- all usage of this path will fail without ".decode('utf-8')" added!
This effects all path's returned by getAddonInfo (because it returns string - not unicode) - you ALWAYS have to decode it properly.
In most cases the addons are using this path for icons, something like:
This will silently fail because xbmc skips images which aren't accessable - this won't be noticed by most users...
More bad is something like:
This will fail with a script error: "WindowsError: [Error 3] The system cannot find the path specified."
But it can even avoid some addons from running with something like this:
Maybe a better solution would be that xbmc would return unicode-instances (and not str)...
Until that we have to do something like:
Don't get me wrong - my Addons are also affected...
regards,
sphere
while reading the forum I found this thread: http://forum.xbmc.org/showthread.php?tid...pid1039311
I did a few tests and can confirm that it is very easy to reproduce and effects most addons - in a not so unrealistic scenario:
- You just need an unicode letter in the xbmc path (which contains the windows-username on windows7). Not sure on the other OS's...
You can easy reproduce this (or test your addons) with starting xbmc in portable mode (add "-p" to you xbmc start shortcut) from a xbmc folder which contains an unicode letter, "ä" or "é" for example.
So just download xbmc again, install it to "C:\folder-with-unicode-ä-é\xbmc" and start "C:\folder-with-unicode-ä-é\xbmc\xbmc.exe -p".
You can also test it with starting xbmc with a local windows username which contans unicode-letters.
I cloned the eden plugins repo and got ~200 line matches without a real unicode decoding:
Code:
getAddonInfo('path')
This effects all path's returned by getAddonInfo (because it returns string - not unicode) - you ALWAYS have to decode it properly.
In most cases the addons are using this path for icons, something like:
Code:
ICON = os.path.join(ADDON.getAddonInfo('path'), 'icon.png')
More bad is something like:
Code:
f = open(os.path.join( __settings__.getAddonInfo('profile'), "allmovies"),'wb')
But it can even avoid some addons from running with something like this:
Code:
sys.path.append(os.path.join(Addon(ADDON_ID).getAddonInfo("path"), "resources", "lib" ))
import module_in_the_above_path
Maybe a better solution would be that xbmc would return unicode-instances (and not str)...
Until that we have to do something like:
Code:
Addon.getAddonInfo('path').decode('utf-8')
Don't get me wrong - my Addons are also affected...
regards,
sphere