"UnicodeDecodeError" problem in Czech setup (WAS: [Spambayes] Re: Spambayes Digest, Vol 59, Issue 9)

Mark Hammond mhammond at skippinet.com.au
Sun Jul 6 18:49:27 EDT 2003


[Skip]
>     Erik> Let me know what kind of experiments I should run.
>
> I can think of a couple things you might try.  First, if
> execute the Python
> interpreter from a DOS shell what is your default encoding (I suspect
> ascii):
>
>     import sys
>     print sys.getdefaultencoding()
>
> Second, I'd like to know what the arguments are to the ntpath.join()
> function.

The arguments should be the literal strings in the source, plus the result
of:

>>> from win32com.shell import shell, shellcon
>>> shell.SHGetFolderPath(0,shellcon.CSIDL_APPDATA,0,0)
u'E:\\Documents and Settings\\skip\\Application Data'
>>>

Which is unicode - so the extended characters "should" work.

Note that Python 2.3 has grown support for Unicode filenames - hence I am
quite keen to know why this is broken.  Even though:


The character with ordinal 0xed (an accented 'i')
> is clearly not
> an ASCII character, yet the error message suggests
> ntpath.join is being
> passed string objects not Unicode objects.  In
> Outlook2000/manager.py you
> should see a bit of code at the start of LoadConfig like this:
>
>     def LoadConfig(self):
>         profile_name = self.message_store.GetProfileName()
>         if profile_name is None:
>             # should only happen in source-code versions -
> older win32alls can't
>             # determine this.
>             profile_name = "unknown_profile"
>         else:
>             # xxx - remove me sometime - win32all grew this
> post 154(ish)
>             # binary never released with this, so we can be a
> little more brutal
>             # Try and rename to current profile, silent failure
>             try:
>                 os.rename(os.path.join(self.data_directory,
> "unknown_profile.ini"),
>                           os.path.join(self.data_directory,
> profile_name + ".ini"))
>             except os.error:
>                 pass
>
> One of those two os.path.join (aka ntpath.join on Windows)
> calls is what's
> failing.  It would appear either your data directory or your
> chosen profile
> name contains an accented 'i'.  One or both should be Unicode
> objects, not
> strings.  If your system has filenames which contain
> non-ASCII characters I
> suspect your system's default encoding needs to be set properly in
> c:\Python23\site.py.
>
> Skip




More information about the Spambayes mailing list