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

Nick Coghlan ncoghlan at gmail.com
Fri May 10 15:53:37 CEST 2013


On Fri, May 10, 2013 at 11:46 PM, Christian Heimes <christian at python.org> wrote:

Am 10.05.2013 14:16, schrieb Antoine Pitrou:

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. POSIX only defines the dino and dname members of struct dirent. Linux, BSD and probably some other platforms also happen to provide dtype. The other members of struct dirent (dreclen, dnamlen) aren't useful in Python space by themselves. dtype and stmode aren't compatible in any way. As you know stmode also contains POSIX permission information. The file type is encoded with a different set of bits, too. Future file types aren't mapped to SIF* constants for stmode.

Why are we exposing a bitfield as the primary Python level API, anyway? It makes sense for the well defined permission bits, but why are we copying the C level concept for the other flags?

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list