[Python-Dev] My summary of the scandir (PEP 471)

Nick Coghlan ncoghlan at gmail.com
Tue Jul 1 18:50:48 CEST 2014

On 1 July 2014 08:42, Ben Hoyt <benhoyt at gmail.com> wrote:
>> We need per-iteration error handling for the readdir call anyway, so I think
>> an onerror callback is a better option than dropping the ability to easily
>> obtain full stat information as part of the iteration.
> I don't mind the idea of an "onerror" callback, but it's adding
> complexity. Putting aside the question of caching/timing for a second
> and assuming .lstat() as per the current PEP 471, do we really need
> per-iteration error handling for readdir()? When would that actually
> fail in practice?

An NFS mount dropping the connection or a USB key being removed are
the first that come to mind, but I expect there are others. I find
it's generally better to just assume that any system call may fail for
obscure reasons and put the infrastructure in place to deal with it
rather than getting ugly, hard to track down bugs later.


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

More information about the Python-Dev mailing list