Issue 26248: Improve scandir DirEntry docs, especially re symlinks and caching (original) (raw)
Created on 2016-01-31 16:43 by benhoyt, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (7)
Author: Ben Hoyt (benhoyt) *
Date: 2016-01-31 16:43
Per Guido's comment about DirEntry documentation on Issue 26032, especially http://bugs.python.org/issue26032#msg257665, it'd be good to improve the docs of the scandir DirEntry methods with regard to symlinks and caching.
Attaching my stab at a documentation fix. Changes here are:
- Clarify that the return values of is_dir()/is_file()/etc are cached separately for follow_symlinks True and False.
- Be more specific about when the functions require a system call, and how it relates to caching and follow_symlinks.
- DRY up common stuff between is_dir and is_file by saying "Caching, system calls made, and exceptions raised are as per is_dir" in is_file.
- Tweak to the first paragraph of docs for is_dir/is_file to simplify: assume the follow_symlinks=True default, then note the follow_symlinks=False non-default case after.
I think they're all improvements, though I'm not sure about #3. Is it better to just repeat those couple of paragraphs verbatim?
I'm also not 100% sure about mentioning the DT_UNKNOWN thing. But you really can't get more specific about when system calls are required on Unix without mentioning it.
Author: Roundup Robot (python-dev) 
Date: 2016-01-31 17:37
New changeset f2c68cb17e31 by Victor Stinner in branch '3.5': Enhance os.scandir() doc https://hg.python.org/cpython/rev/f2c68cb17e31
Author: STINNER Victor (vstinner) * 
Date: 2016-01-31 17:40
The change looks good to me. I pushed it to 3.5 & 3.6. It will be online in a few hours at: https://docs.python.org/dev/library/os.html#os.DirEntry
I keep the issue open a few days to see if some others have other suggestions.
Author: Ben Hoyt (benhoyt) *
Date: 2016-02-01 14:18
Thanks, Victor!
Author: Ben Hoyt (benhoyt) *
Date: 2016-02-05 13:03
Seeing this has been merged (thanks Victor), can this issue be closed? Guido, are you happy with the changes given your comments at http://bugs.python.org/issue26032#msg257665?
Author: STINNER Victor (vstinner) * 
Date: 2016-02-05 14:04
Ben Hoyt added the comment:
Seeing this has been merged (thanks Victor), can this issue be closed?
As I wrote, I left the issue open for wait for feedback. I know that some people to read the doc online: https://docs.python.org/dev/library/os.html#os.DirEntry
Author: Guido van Rossum (gvanrossum) * 
Date: 2016-02-05 21:25
Thanks very much for all that added information!
History
Date
User
Action
Args
2022-04-11 14:58:27
admin
set
github: 70436
2016-03-18 16:20:07
ezio.melotti
set
type: enhancement
stage: resolved
2016-02-05 21:25:03
gvanrossum
set
status: open -> closed
resolution: fixed
messages: +
2016-02-05 14:04:45
vstinner
set
messages: +
2016-02-05 13:03:36
benhoyt
set
messages: +
2016-02-01 14🔞10
benhoyt
set
messages: +
2016-01-31 17:40:25
vstinner
set
messages: +
2016-01-31 17:37:46
python-dev
set
nosy: + python-dev
messages: +
2016-01-31 16:43:42
benhoyt
create