[issue42493] pathlib.Path.__eq__ should test normalized path
Eryk Sun
report at bugs.python.org
Sat Nov 28 17:02:08 EST 2020
Eryk Sun <eryksun at gmail.com> added the comment:
The __eq__ method would have to do a full resolve(), which is expensive and may fail. One can't simply resolve "/foo/symlink/.." as "/foo", where "symlink" is a filesystem symlink. The target has to be resolved before ".." is evaluated, and the link may be invalid or inaccessible. This isn't relevant in Windows because it normalizes ".." components in an opened path with string-based processing before passing the path to the kernel. But, for consistency, one would have to resolve symlinks before comparing paths in Windows as well.
I think if you need this in-depth comparison, it's better to call resolve() manually when paths aren't superficially equal.
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42493>
_______________________________________
More information about the Python-bugs-list
mailing list