You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
os.lstat() supports dir_fd but is not in os.supports_dir_fd #134993
I had written a script using os.fwalk() and os.lstat(), which was working.
Then I added an if os.lstat in os.supports_dir_fd check and a fallback implementation and observed the fallback path being taken:
It included _add("HAVE_FSTATAT","stat") but not included _add("HAVE_LSTAT","lstat"). I am uncertain whether this was intentionally designed or, in the alternative, we should incorporate it.
Activity
zangjiucheng commentedon Jun 4, 2025
Hi there, I tested this code and reproduce the case as you described.
I noticed the following code in
os.py; it includes all the attributes included insupports_dir_fd.cpython/Lib/os.py
Line 120 in c211130
It included
_add("HAVE_FSTATAT","stat")but not included_add("HAVE_LSTAT","lstat"). I am uncertain whether this was intentionally designed or, in the alternative, we should incorporate it.Reference:
https://linux.die.net/man/2/lstat
pythongh-134993: Add os.lstat() to os.supports_dir_fd
vstinner commentedon Jun 5, 2025
I proposed #135188 to fix the issue.
gh-134993: Add os.lstat() to os.supports_dir_fd (#135188)
pythongh-134993: Add os.lstat() to os.supports_dir_fd (pythonGH-135188)
pythongh-134993: Add os.lstat() to os.supports_dir_fd (pythonGH-135188)
vstinner commentedon Jun 6, 2025
Fixed. Thanks for your report.
In the meanwhile, don't rely on
os.supports_dir_fdbut makes the assumption thatos.lstat()supports dir_fd.[3.13] gh-134993: Add os.lstat() to os.supports_dir_fd (GH-135188) (#…
[3.14] gh-134993: Add os.lstat() to os.supports_dir_fd (GH-135188) (#…
pythongh-134993: Add os.lstat() to os.supports_dir_fd (python#135188)
pythongh-134993: Add os.lstat() to os.supports_dir_fd (python#135188)
pythongh-134993: Add os.lstat() to os.supports_dir_fd (python#135188)
[3.12] gh-157579: Fix race condition in the cleanup of tempfile.Tempo…
pythongh-134993: Add os.lstat() to os.supports_dir_fd (python#135188)