Message195735
2013/8/21 Nick Coghlan <report@bugs.python.org>:
> Which reminds me: I'm curious what "ls" currently does for malformed
> filenames. The aim of this change would be to get 'python -c "import os;
> print(os.listdir())"' to do the best it can to work without losing data in
> such a situation.
The "ls" command works on bytes, not on characters. You can
reimplement "ls" with:
* Unicode: os.listdir(str), os.fsencode() and sys.stdout.buffer
* bytes: os.listdir(bytes) and sys.stdout.buffer
os.fsencode() does exactly the opposite of os.fsdecode(). There is a
unit test to check that :-)
I ensured that all OS functions can be used directly with bytes
filenames in Python 3. That's why I added os.environb for example. |
|
Date |
User |
Action |
Args |
2013-08-21 00:37:10 | vstinner | set | recipients:
+ vstinner, lemburg, ncoghlan, pitrou, abadger1999, benjamin.peterson, ezio.melotti, a.badger, r.david.murray |
2013-08-21 00:37:10 | vstinner | link | issue18713 messages |
2013-08-21 00:37:09 | vstinner | create | |
|