Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-71189: Support all-but-last mode in os.path.realpath()#117562
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
gh-71189: Support all-but-last mode in os.path.realpath() #117562
Uh oh!
There was an error while loading. Please reload this page.
Conversation
serhiy-storchaka commented May 20, 2025
The original patch was created in 2016, but it has been rewritten from scratch several times as the |
zooba left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change seems fine to me. I have no opinion on whether it's worth adding the functionality (calling realpath(dirname(p)) seems like a sufficient approach in any case that's useful - if I might need the real filename then I probably need to know whether it's real or not, so this option doesn't help me).
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Steve Dower <[email protected]>
serhiy-storchaka commented Jul 29, 2025
This is not so simple. The last component may be a link which refers to a path in which only the last component does not exist. For example: $ ln -s dir/sub/file link $ realpath linkrealpath: link: No such file or directory $ mkdir dir $ realpath linkrealpath: link: No such file or directory $ mkdir dir/sub $ realpath link/tmp/dir/sub/fileThis is also the default mode of |
zooba commented Jul 29, 2025
Oh okay, so it's only for the case where the last segment is a link but the last segment of the target doesn't exist? In your example above, what would |
serhiy-storchaka commented Jul 29, 2025
It shows This is yet one difference from resolving the parent -- it must also be a directory. |
zooba commented Jul 29, 2025
Makes sense. Still can't think of what I'd use it for, but being able to easily match a POSIX tool's defaults seems reasonable enough. |
9d3b53c into python:mainUh oh!
There was an error while loading. Please reload this page.
bedevere-bot commented Jul 30, 2025
|
Uh oh!
There was an error while loading. Please reload this page.