[issue1272] Decode __file__ and co_filename to unicode using fs default

Christian Heimes report at bugs.python.org
Sun Oct 14 18:22:53 CEST 2007


Christian Heimes added the comment:

Alexandre Vassalotti wrote:
> Alexandre Vassalotti added the comment:
> 
> I thought of another way to implement PyUnicode_DecodeFSDefault. If
> Py_FileSystemDefaultEncoding is set, decode with the codecs module,
> otherwise use UTF-8 + replace. This works because when
> Py_FileSystemDefaultEncoding is initialized at the end of
> Py_InitializeEx(), the codecs module is ready to be used. Here's what
> it looks like:

That's almost what I had in mind but with two exceptions for __APPLE__
and MS_WINDOWS. For both OS the value of Py_FileSystemDefaultEncoding is
hard coded to UTF-8 / MBCS. In your code the method would use
PyUnicode_Decode() too early but you can work around the problem with
two #if defined.

Christian

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1272>
__________________________________


More information about the Python-bugs-list mailing list