This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年06月28日 12:04 by hynek, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (11) | |||
|---|---|---|---|
| msg164249 - (view) | Author: Hynek Schlawack (hynek) * (Python committer) | Date: 2012年06月28日 12:04 | |
>>> n = os.open('/tmp', os.O_RDONLY)
>>> l = os.listdir(n)
>>> os.listdir in os.supports_dir_fd
False
|
|||
| msg164290 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年06月28日 20:03 | |
I want to mark this as wontfix. >>> os.listdir in os.supports_fd True The concept we're struggling with here: is the "fd" you pass in to os.listdir a "dir_fd"? I claim that it isn't. I'm trying to enforce the concept, in both the documentation and the code, that "dir_fd" is a directory fd *accompanying a path*. With listdir, it isn't accompanied by a path, it replaces the path. So I suggest it's not a "dir_fd", it's just an "fd" which by sheer coincidence happens to reference a directory. I proposed making os.listdir accept dir_fd, and internally use open and listdir to emulate the behavior. But someone (Antoine?) rightly pointed out, this would break the guideline that POSIX os.* functions on Unix-y OSes are atomic. I might go so far as to say this needs a documentation fix. But I won't condone any sort of code fix (like adding os.listdir to os.supports_dir_fd). |
|||
| msg164291 - (view) | Author: Hynek Schlawack (hynek) * (Python committer) | Date: 2012年06月28日 20:23 | |
I don't really care about the name but I'd really like some way to check whether listdir supports fds. |
|||
| msg164292 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年06月28日 20:38 | |
Like I said: use os.supports_fd. |
|||
| msg164294 - (view) | Author: Hynek Schlawack (hynek) * (Python committer) | Date: 2012年06月28日 21:12 | |
Ah sorry, that wasn't in the mail (stupid >>>). |
|||
| msg164301 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年06月28日 23:50 | |
I'm closing this. os.listdir should not be listed in supports_dir_fd, because it has no dir_fd parameter. For reference, we discussed all this previously in issue #15176. |
|||
| msg164314 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年06月29日 05:58 | |
> I proposed making os.listdir accept dir_fd, and internally use open and listdir to emulate the behavior. Hmm, I understood the issue as the request for adding dir_fd argument to os.listdir. openat+fdopendir+readdir+closedir+close or, in Python, def listdir2(path, dir_fd=None): fd = os.open(path, dir_fd) try: return os.listdir(fd) finally: os.close(fd) > But someone (Antoine?) rightly pointed out, this would break the guideline that POSIX os.* functions on Unix-y OSes are atomic. os.listdir is not atomic. opendir+readdir+closedir+close or fdup +fdopendir+readdir+closedir+close. |
|||
| msg164315 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年06月29日 06:25 | |
Storchaka: please take it up with Antoine, he's the defender of the realm for POSIX-functions-are-atomic iirc. I'd be happy with dir_fd for os.listdir, though it may be too late for 3.3 anyway. |
|||
| msg164317 - (view) | Author: Hynek Schlawack (hynek) * (Python committer) | Date: 2012年06月29日 06:32 | |
Just in my defense: Larry suggested in msg164245 to me to check for listdir in supports_dir_fd so I just assumed it's broken as it didn't work. I'm totally fine with the current behavior, the discussion about dir_fd support in listdir isn't what I intended with this ticket. |
|||
| msg164318 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年06月29日 07:20 | |
> Storchaka: please take it up with Antoine, he's the defender of the realm for POSIX-functions-are-atomic iirc. I'd be happy with dir_fd for os.listdir, though it may be too late for 3.3 anyway. I know that this is possible (and relatively easy), but I don't think it's useful. If you use at-functions, then after listdir should be at-function, and for this purpose you need to get directory's fd in any case. I don't see useful use cases for listdir(name, dir_fd). So I'm not going to open a new issue and I'm happy with closing this one. |
|||
| msg164319 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年06月29日 08:24 | |
WFM. That is, unless people want to bring up additional only-tangentially-related topics to annoy Hynek ;-) How about those <local sports team>? They're really having a year of it, aren't they! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:32 | admin | set | nosy:
+ georg.brandl github: 59422 |
| 2012年06月29日 08:24:25 | larry | set | messages: + msg164319 |
| 2012年06月29日 07:20:46 | serhiy.storchaka | set | messages: + msg164318 |
| 2012年06月29日 06:32:45 | hynek | set | messages: + msg164317 |
| 2012年06月29日 06:25:43 | larry | set | nosy:
+ pitrou messages: + msg164315 |
| 2012年06月29日 05:58:22 | serhiy.storchaka | set | messages: + msg164314 |
| 2012年06月28日 23:50:37 | larry | set | status: open -> closed resolution: not a bug messages: + msg164301 stage: needs patch -> resolved |
| 2012年06月28日 21:12:43 | hynek | set | messages: + msg164294 |
| 2012年06月28日 20:38:04 | larry | set | messages: + msg164292 |
| 2012年06月28日 20:23:35 | hynek | set | messages: + msg164291 |
| 2012年06月28日 20:03:45 | larry | set | messages: + msg164290 |
| 2012年06月28日 18:26:18 | Arfrever | set | nosy:
+ Arfrever |
| 2012年06月28日 14:36:11 | hynek | link | issue15218 dependencies |
| 2012年06月28日 14:20:54 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka |
| 2012年06月28日 12:04:20 | hynek | create | |