[issue40654] shutil.copyfile mutates symlink for absolute path

Steve Dower report at bugs.python.org
Mon May 18 10:33:18 EDT 2020


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

Ah right, it's realpath() that has the final step to remove an unnecessary \\?\ prefix.

Firstly, I still think fixing copy is more important and more valuable.

Given the possibility that the print name won't point to the real target, I'd much prefer to keep reading the substitute name. In this case, this looks like a change between versions (3.7->3.8) rather than a bug (assuming the symlink works, which hasn't been mentioned yet), and while it does result in needing a test update in Path, I don't think it makes sense to push that fix upstream. Changing readlink to always return the correct path was deliberate.

Unless you're specifically testing single steps through symlink chains, you probably want to just use realpath anyway. Presumably you weren't using that beforehand because it didn't work, but the same fix fixed that, and we do extra work to retain the existing behaviour of the higher-level function (including rejecting junctions, unlike readlink).

----------

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


More information about the Python-bugs-list mailing list