classification
Title: normpath() sometimes maps unicode to str
Type: behavior Stage: resolved
Components: Library (Lib), Unicode Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: os.path.normpath doesn't preserve unicode
View: 5827
Assigned To: Nosy List: ezio.melotti, kcwu, loewis, sandberg
Priority: normal Keywords:

Created on 2009-07-09 18:49 by sandberg, last changed 2009-11-14 00:38 by ezio.melotti. This issue is now closed.

Messages (4)
msg90341 - (view) Author: Erik Carstensen (sandberg) Date: 2009-07-09 18:49
On Linux, I get the following:

>>> import os
>>> os.path.normpath(u'/')
'/'

I would expect unicode to be mapped to unicode. os.path.abspath() has
the same problem, see also issue 3426.

This causes problems in my project, where a function requires its
parameters to be Unicode. Do the standard Python library functions that
operate on strings guarantee anything in general with respect to
conserving unicode? Can I make any assumption as to which codec was used
to encode the str returned from normpath?
msg90343 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-07-09 19:02
> Do the standard Python library functions that
> operate on strings guarantee anything in general with respect to
> conserving unicode? Can I make any assumption as to which codec was used
> to encode the str returned from normpath?

The bug tracker is not really a place to ask questions. Please ask them
on python-list or elsewhere, or read the source code of normpath.
msg94965 - (view) Author: Kuang-che Wu (kcwu) Date: 2009-11-06 10:37
see issue 5827, it includes a patch fixing this issue.
msg95222 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-11-14 00:38
Closing this as duplicate of #5827.
History
Date User Action Args
2009-11-14 00:38:19ezio.melottisetstatus: open -> closed
resolution: duplicate
messages: + msg95222

superseder: os.path.normpath doesn't preserve unicode
stage: test needed -> resolved
2009-11-06 10:37:32kcwusetnosy: + kcwu
messages: + msg94965
2009-07-09 19:02:57loewissetnosy: + loewis
messages: + msg90343
2009-07-09 19:02:07ezio.melottisetversions: + Python 2.7
nosy: + ezio.melotti

priority: normal
components: + Unicode
stage: test needed
2009-07-09 18:49:55sandbergcreate