module import from current directory fails if non-english character is in path
#1
I recently added a error reporting feature to my addon (cinemassacre).
I have noticed I get alot of reports of a 'ImportError' from people who have non-english characters in their path.

Such as this trace:
Code:
Traceback (most recent call last):
File "C:\Users\testöåätest\AppData\Roaming\XBMC\addons\plugin.video.cinemassacre\default.py", line 6, in
import thisCommonFunctions as common2
ImportError: No module named thisCommonFunctions

Looking around it seems that python imports modules based on what is in 'sys.path'
I dumped this variable to the log and this is what it returned:
Code:
['C:\\Users\\testtest\\AppData\\Roaming\\XBMC\\addons\\plugin.video.cinemassacre', 'C:\\Program Files\\XBMC\\addons\\script.module.pil\\lib', 'C:\\Program Files\\XBMC\\addons\\xbmc.debug\\', 'C:\\Users\\test\xf6\xe5\xe4test\\AppData\\Roaming\\XBMC\\addons\\script.common.plugin.cache\\lib', 'C:\\Users\\test\xf6\xe5\xe4test\\AppData\\Roaming\\XBMC\\addons\\script.module.parsedom\\lib', 'C:\\Users\\test\xf6\xe5\xe4test\\AppData\\Roaming\\XBMC\\addons\\script.module.simple.downloader\\lib', 'C:\\Users\\test\xf6\xe5\xe4test\\AppData\\Roaming\\XBMC\\addons\\script.module.simplejson\\lib', 'C:\\Program Files\\XBMC\\system\\python\\DLLs', 'C:\\Program Files\\XBMC\\system\\python\\Lib', 'C:\\Program Files\\XBMC\\python27.zip', 'C:\\Program Files\\XBMC\\system\\python\\lib\\plat-win', 'C:\\Program Files\\XBMC\\system\\python\\lib\\lib-tk', 'C:\\Program Files\\XBMC', 'C:\\Program Files\\XBMC\\system\\python', 'C:\\Program Files\\XBMC\\system\\python\\lib\\site-packages']

As you can see, for some reason xbmc is striping out the unicode from the current directory path before adding it to the sys.path ('C:\\Users\\testtest\\AppData\\Roaming\\XBMC\\addons\\plugin.video.cinemassacre')

It looks like this only happens to the current directory because addon modules such as 'script.module.parsedom' keeps the unicode intact ('C:\\Users\\test\xf6\xe5\xe4test\\AppData\\Roaming\\XBMC\\addons\\script.module.parsedom\\lib')

This happens to all addons that import modules from their current directory.
This is the sys.path for the youtube addon:
Code:
'C:\\Users\\testtest\\AppData\\Roaming\\XBMC\\addons\\plugin.video.youtube', 'C:\\Program Files\\XBMC\\addons\\script.module.pil\\lib', 'C:\\Program Files\\XBMC\\addons\\xbmc.debug\\', 'C:\\Users\\test\xf6\xe5\xe4test\\AppData\\Roaming\\XBMC\\addons\\script.common.plugin.cache\\lib', 'C:\\Users\\test\xf6\xe5\xe4test\\AppData\\Roaming\\XBMC\\addons\\script.module.parsedom\\lib', 'C:\\Users\\test\xf6\xe5\xe4test\\AppData\\Roaming\\XBMC\\addons\\script.module.simple.downloader\\lib', 'C:\\Users\\test\xf6\xe5\xe4test\\AppData\\Roaming\\XBMC\\addons\\script.module.simplejson\\lib', 'C:\\Program Files\\XBMC\\system\\python\\DLLs', 'C:\\Program Files\\XBMC\\system\\python\\Lib', 'C:\\Program Files\\XBMC\\python27.zip', 'C:\\Program Files\\XBMC\\system\\python\\lib\\plat-win', 'C:\\Program Files\\XBMC\\system\\python\\lib\\lib-tk', 'C:\\Program Files\\XBMC', 'C:\\Program Files\\XBMC\\system\\python', 'C:\\Program Files\\XBMC\\system\\python\\lib\\site-packages'


I manage to work around this by first importing "os and sys",
then running "sys.path.append(os.path.dirname(__file__))"

This works fine for my addon, but if I get a video url that I pass off to another addon such as for youtube, it will ofc fail.

I hope I explained this clearly enough, just thought I would report it, as to me it does seem like a bug in xbmc and not anything addon dependent.
Reply
#2
Nevermind, I just tested this on the most recent snapshot, and it appears to already have been fixed, I guess I should have checked on that first.
Reply

Logout Mark Read Team Forum Stats Members Help
module import from current directory fails if non-english character is in path0