-
-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
os.path.realpath('loop/../link')
does not resolve link
#117546
Comments
As Barney noted, this is only an issue on POSIX. The non-strict implementation on Windows ignores a symlink loop to resolve as much as possible. Also, on Windows, for the given examples, the ".." component gets resolved first, which is like the |
…/link')` Continue resolving symlink targets after encountering a symlink loop, which matches coreutils `realpath` behaviour.
Thanks Eryk! I suppose users could do |
This behaviour goes back to Python 2. IMO, we should be very careful when changing it. The status quo seems fine. I don't feel qualified to review this. |
Appreciate the feedback. Serhiy has separately approved the change, but given your reservations, I won't merge yet. Hopefully another core dev comes along to share their views and perhaps cast the deciding vote (if not I'll summon one in due course). This bug is pretty rare. To hit it you need to supply a path that:
The unlikelihood of hitting all three might explain why I couldn't find any existing bug reports, despite the bug going way back :) |
Serhiy is the os.path expert, he should get the deciding vote. I am careful because I'm not familiar with os.path maintenance :) I agree that this is an edge case you hopefully won't see in production. |
…)` (#117568) Continue resolving symlink targets after encountering a symlink loop, which matches coreutils `realpath` behaviour.
Thanks! Fix merged into |
…/link')` (python#117568) Continue resolving symlink targets after encountering a symlink loop, which matches coreutils `realpath` behaviour.
If
os.path.realpath()
encounters a symlink loop on posix, it prematurely stops querying paths and resolving symlink targets. This differs from coreutilsrealpath
:It also differs from how
lstat()
errors are handled:$ realpath -m missing/../link /tmp/target $ python -c 'import os.path; print(os.path.realpath("missing/../link"))' /tmp/target
Linked PRs
os.path.realpath('loop/../link')
#117568The text was updated successfully, but these errors were encountered: