[Python-Dev] PEP 471: scandir(fd) and pathlib.Path(name, dir_fd=None)

"Martin v. Löwis" martin at v.loewis.de
Mon Jul 7 08:39:07 CEST 2014

Am 01.07.14 09:44, schrieb Victor Stinner:
> scandir(fd) must not close the file descriptor, it should be done by
> the caller. Handling the lifetime of the file descriptor is a
> difficult problem, it's better to let the user decide how to handle
> it.

This is an open issue still: when is the file descriptor closed.

I think the generator returned from scandir needs to support a
.close method that guarantees to close the file descriptor.
AFAICT, the pure-Python prototype of scandir already does, but
it should be specified in the PEP.

While we are at it: is it intended that the generator will also
support the other generator methods, in particular .send and


More information about the Python-Dev mailing list