[issue9820] Windows : os.listdir(b'.') doesn't raise an errorfor unencodablefilenames
report at bugs.python.org
Mon Sep 13 13:50:47 CEST 2010
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
> I fail to see why removing incorrect file names from the result
> list is any better than keeping them. The result list will
> be incorrect either way.
It depends if you focus on displaying the content of the directory, or on processing files and directories. If you focus on display, yes, missing files an be seen as a bug. But if you walk into directories (use cases: os.walk(), replace a text pattern in all files (~os.glob), ...), and the function raises an error (because a directory or a file name is invalid) is worse. I mean the user have to rename all unencodable names, or the devfeloper have to patch its application to catch IOError and ignore the specific IOError(22).
If listdir() ignores unencodable names, os.walk() doesn't fail, but it misses some subdirectories and files.
Another (worse?) idea: deny bytes path for os.listdir(), but I suppose that we will not like the idea ;-)
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list