[issue40654] shutil.copyfile mutates symlink for absolute path

Steve Dower report at bugs.python.org
Mon May 25 15:49:29 EDT 2020


Steve Dower <steve.dower at python.org> added the comment:

I think we can safely say this is by design (I know Jason got his backport working).

> Understood. However, this statement assumes the "correct path" is the most precise path to resolve the target. If you instead define "correct path" as the one that would be most friendly to the user who created the path, readlink no longer honors that expectation.

Nothing about the os module is meant to be user-friendly first - it's based on the POSIX spec ;)

The most important thing is that operations that traverse symlinks should end up at the same file as a manual traversal using readlink. The easiest way to spoil this is to optimise for readability over correctness.

As discussed, realpath does a little more work to ensure readability, and anything else that cares about UI can do similar work. But if the lowest-level function loses critical information, there's no way for the developer to get it back.

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40654>
_______________________________________


More information about the Python-bugs-list mailing list