Closed as not planned
Description
Feature or enhancement
Proposal:
glob
currently needs its own implementation of os.path.lexists()
& os.path.isdir()
to support dir_fd
:
Lines 201 to 222 in f74e512
We could refactor this by adding dir_fd
to os.path.lexists()
& os.path.isdir()
:
-def lexists(path):
+def lexists(path, *, dir_fd: int | None = None):
"""Test whether a path exists. Returns True for broken symbolic links"""
try:
- os.lstat(path)
+ os.lstat(path, dir_fd=dir_fd)
except (OSError, ValueError):
return False
return True
-def isdir(s):
+def isdir(s, *, dir_fd: int | None = None):
"""Return true if the pathname refers to an existing directory."""
try:
- st = os.stat(s)
+ st = os.stat(s, dir_fd=dir_fd)
except (OSError, ValueError):
return False
return stat.S_ISDIR(st.st_mode)
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
Metadata
Metadata
Assignees
Labels
Python modules in the Lib dirPython modules in the Lib dirA feature request or enhancementA feature request or enhancement