Created
April 8, 2015 15:39
-
-
Save adiroiban/d6674474c84f4516925b to your computer and use it in GitHub Desktop.
Unicode os.stat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-> os.stat(path) | |
(Pdb) path | |
u'/tmp/4b385cfb-f96c-4eca-81c9-70d1223353d6-cp\u021b/3741-cp\u021baaaaaaaaaaaaaaaaaaaaaaaa' | |
(Pdb) os.stat(path) | |
*** UnicodeEncodeError: 'ascii' codec can't encode character u'\u021b' in position 44: ordinal not in range(128) | |
(Pdb) os.stat(path.encode('utf-8')) | |
*** OSError: [Errno 2] No such file or directory: '/tmp/4b385cfb-f96c-4eca-81c9-70d1223353d6-cp\xc8\x9b/3741-cp\xc8\x9baaaaaaaaaaaaaaaaaaaaaaaa' | |
(Pdb) os.environ.get('LANG') | |
'C' | |
(Pdb) os.stat(path) | |
*** UnicodeEncodeError: 'ascii' codec can't encode character u'\u021b' in position 44: ordinal not in range(128) | |
(Pdb) sys.getfilesystemencoding() | |
'ANSI_X3.4-1968' | |
(Pdb) os.environ['LANG'] = 'C' | |
(Pdb) sys.getfilesystemencoding() | |
'ANSI_X3.4-1968' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment