-
-
Notifications
You must be signed in to change notification settings - Fork 32k
properly define what "canonical" means in os.path.realpath
#134639
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
Comments
|
Hmm. I think even Your example is true, though IMO canonical does not mean whether or not the resulting paths are then relative (I would however say the word implies normalised). In your example, assuming a cwd of From my testing, What I'm a bit unsure about how to deal with is, that it also normalises absolute pathnames with exactly two leading
Which in pure POSIX is IMO wrong, as Some Python library parts do in fact account for this, e.g.
So I'm tempted to say, that Unless anyone strongly disagrees, I'd open a separate issue for that particular aspect. |
Improve documentation for os.path.realpath by clearly defining what a "canonical path" means. The updated documentation now explicitly states that a canonical path: - Is an absolute path - Has all symbolic links resolved - Is normalized (redundant separators, '.' and '..' components removed) Also clarify platform-specific behavior: - On Windows: resolves MS-DOS (8.3) style names and junction points - On POSIX: roughly equivalent to the system's realpath() function Closes python#134639
Uh oh!
There was an error while loading. Please reload this page.
Documentation
The documentation says:
cpython/Doc/library/os.path.rst
Lines 406 to 409 in 2fd09b0
So it merely mentions symlink resolution, but not what else it means (if anything).
It does however mention that whatever it does is OS dependent:
cpython/Doc/library/os.path.rst
Lines 416 to 418 in 2fd09b0
IMO, it should be clearly documented what it does or at least:
and/or:
Especially since IMO "canonical" pathname (though I think it has no formal definition, or is there anything in POSIX?) means rather just that there are no symlinks left, i.e. that the file is "reached" by its true (=canonical) name.
But that could still be a relative pathname, and perhaps even one that is not normalised.
Cheers,
Chris.
Linked PRs
The text was updated successfully, but these errors were encountered: