gh-85004: Add the printname parameter in os.readlink() - #155425
serhiy-storchaka wants to merge 2 commits into
Conversation
On Windows it makes the function return the print name of the link -- the target path as it was specified when the link was created.
Documentation build overview
402 files changed ·
|
|
The change looks good to me overall - just want to throw out the possibility that a Boolean keyword argument might not be the best option here? Maybe some kind of enum or string literal would read nicer and leave us a better future option? n = readlink(path, printname=True)
# or
n = readlink(path, kind="print") # or "target" or ...
# or
n = readlink(path, index=1) # defaults to 0, or maybe -1 to preserve current behaviors/errorsI don't know what variations of Best example I can think of is that we chose not to support reading appexec aliases with this function, even though on Windows they're the same kind of thing (example code from PyManager). But those have a number of fields you would read out, so a single bool isn't a great field compared to the index or names (which we'd have to choose and hard code, since they're not in the data structure itself). No big deal. |
The print name is optional --
[MS-FSCC]only says that it SHOULD be set, and PowerShell'sNew-Item -ItemType Junctiondoes not set one -- so the substitute name is returned for a link which has none. Converting the\??\prefix to\\?\is skipped for the print name, which is not in the NT namespace. On non-Windows platforms the parameter is ignored, as a POSIX symlink has only one target path.