[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Looks as this is a duplicate of issue13247. And Victor submitted a patch with approach similar to me (except that my patch does not raises an exception, but returns an unicode for unencodable names). It looks as longliving design bug and perhaps really be

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: Indeed, os.listdir() should always be called with a unicode argument under Windows (which is the natural thing to do in 3.x, anyway). The other issue (with print() unable to display some symbols depending on the codepage) is unrelated. -- nosy:

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-15 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: Anatoly, - in Python2.7, try this: print repr(os.listdir(u'.')) - in Python3, try this: print(ascii(os.listdir('.'))) Do the commands above work correctly? -- ___ Python tracker rep...@bugs.python.org

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- title: os.walk ignores international dirs on Windows - os.listdir() returns unusable bytes result on Windows ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread R. David Murray
R. David Murray added the comment: Oh, I remember Victor complaining about that behavior of Windows. I'm pretty sure it is the windows API and not python that is doing that mangling. But Victor would know for sure. -- ___ Python tracker

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread Larry Hastings
Larry Hastings added the comment: I'm a little confused. FindFirstFile is an ANSI API, so we get a narrow string back. We call PyBytes_FromString(), which expects a narrow string and returns a bytes object. Who's trying (and failing) to encode the filename? --

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Who's trying (and failing) to encode the filename? Windows. File created using Unicode API and stored UTF-16 encoded in NTFS. Windows fails to represent this filename using ANSI API. Here is a patch against 2.7 which always uses Unicode API in listdir() and

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I can't test (and even compile) the patch as I don't have a Windows, please test it for me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread STINNER Victor
STINNER Victor added the comment: On Windows with Python 2, unencodable characters are replaced with ?. It is the default behaviour of WideCharToMultiByte() and so all ANSI functions have this behaviour. Python doesn't try to behave differently, it just exposes system function as Python

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@gmail.com: -- resolution: - wont fix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread STINNER Victor
STINNER Victor added the comment: And this issue is only solved in Python 3... Ooops, I mean: this issue is *already* solved in Python 3 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: For example, os.listdir(bytes) doesn't fail in Python 2.7 with unencodable names, whereas it fails with your patch. No. The purpose of this patch is that it doesn't fail and should return a usable result. --

[issue16656] os.listdir() returns unusable bytes result on Windows

2012-12-14 Thread anatoly techtonik
anatoly techtonik added the comment: haypo didn't understood the main user story for this ticket and closed it, so I reopen it with simplified user story. As a developer, I want Python os.listdir('.') function return all directories in current directory on Windows, not matter how