Bug report
On Linux with Python 3.15, os.statx() follows symbolic links even when follow_symlinks=False is passed.
A small reproducer:
import os
import stat
import tempfile
from pathlib import Path
with tempfile.TemporaryDirectory() as directory:
target = Path(directory) / "target"
link = Path(directory) / "link"
target.touch()
link.symlink_to(target)
result = os.statx(link, os.STATX_BASIC_STATS, follow_symlinks=False)
assert stat.S_ISLNK(result.stx_mode), "statx followed the symlink"
The assert statement is triggered because statx follows the symlink:
# /opt/bin/python3.15 -V
Python 3.15.0rc3
# /opt/bin/python3.15 bug.py
Traceback (most recent call last):
File "/root/Python-3.15.0rc3/bug.py", line 13, in <module>
assert stat.S_ISLNK(result.stx_mode), "statx followed the symlink"
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
AssertionError: statx followed the symlink
AT_SYMLINK_NOFOLLOW should likely be added to the statx flags when follow_symlinks is falsely.
CPython versions tested on:
3.15
Operating systems tested on:
Linux
Linked PRs
Bug report
On Linux with Python 3.15, os.statx() follows symbolic links even when
follow_symlinks=Falseis passed.A small reproducer:
The assert statement is triggered because statx follows the symlink:
AT_SYMLINK_NOFOLLOWshould likely be added to the statx flags whenfollow_symlinksis falsely.CPython versions tested on:
3.15
Operating systems tested on:
Linux
Linked PRs