[issue8514] Create fsencode() and fsdecode() functions in os.path

STINNER Victor report at bugs.python.org
Tue May 4 00:31:07 CEST 2010


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

> IIUC, that usage is an equivalent transformation, i.e. the code doesn't
> change its behavior. It is mere refactorization.

I changed os.getenv() to accept byte string key (in a previous commit), but I don't like this hack. If we have os.environb, os.getenv() shouldn't support bytes anymore (but use str only, as before).

--

I worked a little more on fsencode()/os.environb, trying to fix all issues. fsdecode() is no more needed if we have os.environb, and fsencode() can be simplified to:

  def fsencode(value):
     return value.encode(sys.getfilesystemencoding(), 'surrogateescape')

fsdecode() leads to mojibake.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8514>
_______________________________________


More information about the Python-bugs-list mailing list