-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Conversation
The original patch was created in 2016, but it has been rewritten from scratch several times as the |
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).
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
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 link
realpath: link: No such file or directory
$ mkdir dir
$ realpath link
realpath: link: No such file or directory
$ mkdir dir/sub
$ realpath link
/tmp/dir/sub/file This is also the default mode of |
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 |
It shows This is yet one difference from resolving the parent -- it must also be a directory. |
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. |
|
Uh oh!
There was an error while loading. Please reload this page.