[Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info

Ronald Oussoren ronaldoussoren at mac.com
Fri May 10 15:25:01 CEST 2013

On 10 May, 2013, at 14:16, Antoine Pitrou <solipsis at pitrou.net> wrote:

> Le Fri, 10 May 2013 13:46:30 +0200,
> Christian Heimes <christian at python.org> a écrit :
>> Hence I'm +1 on the general idea but -1 on something stat like. IMHO
>> os.scandir() should yield four objects:
>> * name
>> * inode
>> * file type or DT_UNKNOWN
>> * stat_result or None
>> stat_result shall only be returned when the operating systems
>> provides a full stat result as returned by os.stat().
> But what if some systems return more than the file type and less than a
> full stat result? The general problem is POSIX's terrible inertia.
> I feel that a stat result with some None fields would be an acceptable
> compromise here.

But how do you detect that the st_mode field on systems with a d_type is incomplete, as oposed to a system that can return a full st_mode from its readdir equivalent and where the permission bits happen to be 0o0000? One option would be to add a file type field to stat_result, IIRC this was mentioned in some revisions of the extended stat_result proposal over on python-ideas.


> Regards
> Antoine.
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/ronaldoussoren%40mac.com

More information about the Python-Dev mailing list