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

2014-07-06 Thread Martin v. Löwis
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 fil

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

2014-07-02 Thread Charles-François Natali
> 2014-07-02 12:51 GMT+02:00 Charles-François Natali : >> I don't think we should support it: it's way too complicated to use, >> error-prone, and leads to messy APIs. > > Can you please elaborate? Which kind of issue do you see? Handling the > lifetime of the directory file descriptor? Yes, among

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

2014-07-02 Thread Victor Stinner
2014-07-02 12:51 GMT+02:00 Charles-François Natali : > I don't think we should support it: it's way too complicated to use, > error-prone, and leads to messy APIs. Can you please elaborate? Which kind of issue do you see? Handling the lifetime of the directory file descriptor? You don't like the

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

2014-07-02 Thread Charles-François Natali
2014-07-01 8:44 GMT+01:00 Victor Stinner : > > IMO we must decide if scandir() must support or not file descriptor. > It's an important decision which has an important impact on the API. I don't think we should support it: it's way too complicated to use, error-prone, and leads to messy APIs.

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

2014-07-01 Thread Akira Li
Ben Hoyt writes: > Thanks, Victor. > > I don't have any experience with dir_fd handling, so unfortunately > can't really comment here. > > What advantages does it bring? I notice that even os.listdir() on > Python 3.4 doesn't have anything related to file descriptors, so I'd > be in favour of not

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

2014-07-01 Thread Victor Stinner
2014-07-01 14:26 GMT+02:00 Ben Hoyt : > Thanks, Victor. > > I don't have any experience with dir_fd handling, so unfortunately > can't really comment here. > > What advantages does it bring? I notice that even os.listdir() on > Python 3.4 doesn't have anything related to file descriptors, so I'd >

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

2014-07-01 Thread Ben Hoyt
Thanks, Victor. I don't have any experience with dir_fd handling, so unfortunately can't really comment here. What advantages does it bring? I notice that even os.listdir() on Python 3.4 doesn't have anything related to file descriptors, so I'd be in favour of not including support. We can always

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

2014-07-01 Thread Victor Stinner
Hi, IMO we must decide if scandir() must support or not file descriptor. It's an important decision which has an important impact on the API. To support scandir(fd), the minimum is to store dir_fd in DirEntry: dir_fd would be None for scandir(str). scandir(fd) must not close the file descripto