You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
os.path.realpath() resolves the path using the current OS's rules, which might be more specific than POSIX. Both my Linux and macOS machines resolve //foo to /foo. Are there any supported Python platforms where // isn't resolved to /?
I'm currently on my Windows laptop, so I can't check.
In any case, the old implementation can never return //foo because path is set to os.sep.
Is there a "needs investigation" label?
There doesn't seem to be anything like a "needs investigation" label.
Happy to leave this issue open for a bit while you further research a repro case, but if we can't find one, then I think this issue should be closed as "can't repro".
Why do you want to fix this, and could you describe in more detail how the changes relate to the specification you are pointing to? I don't see what in the specification requires this.
Activity
barneygale commentedon Mar 28, 2024
os.path.realpath()resolves the path using the current OS's rules, which might be more specific than POSIX. Both my Linux and macOS machines resolve//footo/foo. Are there any supported Python platforms where//isn't resolved to/?nineteendo commentedon Mar 28, 2024
I'm currently on my Windows laptop, so I can't check.
In any case, the old implementation can never return
//foobecausepathis set toos.sep.Is there a "needs investigation" label?
barneygale commentedon Mar 28, 2024
There doesn't seem to be anything like a "needs investigation" label.
Happy to leave this issue open for a bit while you further research a repro case, but if we can't find one, then I think this issue should be closed as "can't repro".
nineteendo commentedon Mar 28, 2024
Also, the current behaviour is undocumented:
Normalizing doesn't touch the double slash &
//is not a symlink.barneygale commentedon Mar 28, 2024
You're quoting a comment above the internal
_joinrealpath()function.Both the
posixpath.realpath()docstring, and the online docs, describe it as returning a canonical path. The online docs add:nineteendo commentedon Mar 28, 2024
OK, but that comment doesn't document this feature, which it probably should, in case this works correctly.
bluss commentedon Mar 29, 2024
Why do you want to fix this, and could you describe in more detail how the changes relate to the specification you are pointing to? I don't see what in the specification requires this.
nineteendo commentedon Mar 29, 2024
Yep, the old behaviour seems to be correct (cd doesn't resolve symlinks), in that case the feature should just be documented and tested.
[-]Handle leading `//` for `realpath.commonpath`[/-][+]Handle leading `//` for `posixpath.realpath`[/+]barneygale commentedon Mar 29, 2024
We don't need to document every detail of what
realpath()does. Tests would be welcome, thoughnineteendo commentedon Mar 29, 2024
I've added just one sentence in this pull request: #117350.
Where should I add the test though? It doesn't really fit in with the rest of the changes.