-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Add dir_fd
to os.path.lexists()
& os.path.isdir()
#117967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @serhiy-storchaka before I start implementing this: is this something you would support? |
It is trivially implemented via If there will be other uses of such functions in several different places, it will be worth to add this feature. |
They could still be simplified in that case: def _lexists(pathname, dir_fd):
# Same as os.path.lexists()
return os.path.lexists(pathname, dir_fd=dir_fd)
def _isdir(pathname, dir_fd):
# Same as os.path.isdir()
return os.path.isdir(pathname, dir_fd=dir_fd) |
|
The builtin FYI, the NT kernel supports opening relative to a handle, which the Windows API makes use of when opening relative to the working directory. However, it's not directly exposed in the Windows API. A fundamental problem is that ".." components are resolved logically on Windows by the user-mode runtime library. Thus using a safe open on NT requires that the normalized relative path doesn't begin with a ".." component. |
I don't feel strongly about it. I note it would be the first |
I see, I assumed Windows supported it too. Then it can only be used for refactoring
At the moment it only seems to be needed for |
I'm closing this as there's not much support. Feel free to re-open when you change your mind. |
Feature or enhancement
Proposal:
glob
currently needs its own implementation ofos.path.lexists()
&os.path.isdir()
to supportdir_fd
:cpython/Lib/glob.py
Lines 201 to 222 in f74e512
We could refactor this by adding
dir_fd
toos.path.lexists()
&os.path.isdir()
:Note:
nt._path_isdir()
(&nt._path_lexists()
when #117842 lands) need to raise an error for this.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: