[issue27084] Add dir_fd and follow_symlinks kwargs to os.listdir and os.scandir

2016-05-22 Thread Evgeny Kapun
Evgeny Kapun added the comment: Mostly for consistency with other functions. Also, this provides an easy way to walk a directory tree recursively: just call listdir on every member, and if it doesn't raise OSError, that member must be a directory. With follow_symlinks=False, this method wouldn

[issue27084] Add dir_fd and follow_symlinks kwargs to os.listdir and os.scandir

2016-05-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: But why you want to pass O_NOFOLLOW to the underlying open(2) syscall? -- ___ Python tracker ___ _

[issue27084] Add dir_fd and follow_symlinks kwargs to os.listdir and os.scandir

2016-05-22 Thread Evgeny Kapun
Evgeny Kapun added the comment: 1. Yes, it's possible to emulate dir_fd this way, so this is just for convenience. 2. If follow_symlinks is False, O_NOFOLLOW is passed to the underlying open(2) syscall. Of course, this doesn't make sense if a file descriptor is passed already. -- ___

[issue27084] Add dir_fd and follow_symlinks kwargs to os.listdir and os.scandir

2016-05-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: os.listdir() with dir_fd: fd = os.open(path, os.O_RDONLY, dir_fd=dir_fd) try: result = os.listdir(fd) finally: os.close(fd) What meaning of follow_symlinks for os.listdir()? -- nosy: +serhiy.storchaka

[issue27084] Add dir_fd and follow_symlinks kwargs to os.listdir and os.scandir

2016-05-22 Thread Evgeny Kapun
New submission from Evgeny Kapun: Many functions in os module support dir_fd and follow_symlinks keyword arguments. I think that os.listdir and os.scandir should do likewise. See also: issue25996. -- components: Library (Lib) messages: 266091 nosy: abacabadabacaba priority: normal seve