[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-12 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: What do you gain with this patch? (i.e. what is its advantage?) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9820 ___

[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-12 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: What do you gain with this patch? (i.e. what is its advantage?) You know directly that os.listdir(bytes) is unable to encode the filename, instead of manipulate an invalid filename (b'?') and get the error later (when you use the

[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-12 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: You know directly that os.listdir(bytes) is unable to encode the filename, instead of manipulate an invalid filename (b'?') and get the error later (when you use the filename: open, copy, delete, ... the file). Ok. Then I'm -1 on the

[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-10 Thread STINNER Victor
New submission from STINNER Victor victor.stin...@haypocalc.com: In Python 3.2, mbcs encoding (default filesystem encoding on Windows) is now strict: raise an error on unencodable/undecodable characters/bytes. But os.listdir(b'.') encodes unencodable bytes as b'?'. Example:

[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-10 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: I found this bug while trying to find an unencodable filename for #9819 (TESTFN_UNDECODABLE). Anyway, the bytes API should be avoided on Windows since Windows native filename type is unicode. --

[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-10 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: os.listdir(b'listdir') should raise an error (and not ignore the filename or replaces unencodable characters by b'?'). To avoid the error, a solution is to support the PEP 383 on Windows (for the mbcs encoding). I opened a

[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-10 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Patch: - Remove the bytes version of listdir(): reuse the unicode version but converts the filename to bytes using PyUnicode_EncodeFSDefault() if the directory name is not unicode - use Py_XDECREF(d) instead of Py_DECREF(d) at