[issue40654] shutil.copyfile mutates symlink for absolute path

Jason R. Coombs report at bugs.python.org
Fri May 22 12:51:04 EDT 2020


Jason R. Coombs <jaraco at jaraco.com> added the comment:

> Changing readlink to always return the correct path was deliberate.

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. With this change, the following invariant holds on every platform except Python 3.8 on Windows (at least in the general case):

>>> os.symlink(x, y)
>>> assert os.readlink(y) == x

More importantly, AFAIK, Python provides no function to transform `x` into what one can expect as the result of `os.readlink(y)`. In other words, what value of `f` would make this invariant pass?

>>> os.symlink(x, y)
>>> assert os.readlink(y) == f(x)

Or put another way, is "C:\Users\jaraco\temp" an "incorrect path"?

----------

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


More information about the Python-bugs-list mailing list