Uh oh!
There was an error while loading. Please reload this page.
gh-71189: Support all-but-last mode in os.path.realpath() - #117562
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.
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 <steve.dower@microsoft.com>
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. |
Uh 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.