Unicode Module Import

On 12/05/2014 at 10:53, xxxxxxxx wrote:

My Python plugin includes several modules, and I'm using sys.path.insert (and pop) as described elsewhere to import those modules. I've just discovered, though, that this doesn't seem to work with unicode. As far as I can tell, Python doesn't pass unicode strings to sys.path (on Windows at least - haven't tested mac).

Because the recommended install location for C4D plugins is the user prefs folder, this causes module loading to fail if the user has a username with accented (unicode) characters.

Is there any way around this, or is it a fundamental limitation at this point? Have others run into this? Do people with accented names usually use an ascii-equivalent username (sorry for my American English naivete - yes, I'm leaving the accents out of that word because I can't be bothered with unicode).

On 14/05/2014 at 12:31, xxxxxxxx wrote:

Can you please post a short piece of code how you construct the path?

Bye, s_rath

On 14/05/2014 at 14:52, xxxxxxxx wrote:

  
import os,sys   
base_path = unicode(os.path.dirname(__file__),'utf-8')   
lib_path = os.path.join(os.path.dirname(__file__), 'lib')   
sys.path.insert(0, lib_path)   
try:   
    import cvToolboxCore   
    import cvMenus   
finally:   
    sys.path.pop(0)   

On 15/05/2014 at 02:59, xxxxxxxx wrote:

From the bug-reports you posted it seems really to be in issue, that only seems to be fixed in Python 3.2. I will take a look if there is a workaround for this.