[New-bugs-announce] [issue13207] os.path.expanduser brakes when using unicode character in the username

Manuel de la Pena report at bugs.python.org
Tue Oct 18 13:34:29 CEST 2011


New submission from Manuel de la Pena <manuel at canonical.com>:

During our development we have experience the following:

If you have a user in your Windows machine with a name hat uses Japanese characters like “雄鳥お人好し” you will have the following in your system:

* The Windows Shell will show the path correctly, that is: “C:\Users\雄鳥お人好し”
* cmd.exe will show: “C:\Users\??????”
* All the env variables will be wrong, which means they will be similar to the info shown in cmd.exe

The above is a problem because the implementation of expanduser in ntpath.py uses the env variables to get expand the path which means that in this case the returned path will be wrong. 

I have attached a small example of how to get the user profile path (~) on Windows using SHGetFolderPathW or SHGetKnownFolderPathW to fix the issue. 

PS: I don't know if this issue also occurs on python 3.

----------
components: Windows
files: expanduser.py
messages: 145798
nosy: mandel
priority: normal
severity: normal
status: open
title: os.path.expanduser brakes when using unicode character in the username
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file23442/expanduser.py

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


More information about the New-bugs-announce mailing list