`TargetPath` issue when using `samefile` with a stringpath on different python versions
I found this when reviewing https://github.com/fox-it/acquire/pull/255. Path.samefile doesn't function as intended on some of the TargetPath implementations.
These are my findings as of now using TargetPath.samefile(string_path)
-
python3.9 During the
samefilecall it raises anAttributeErrorof it missing a_accessorproperty inside theTargetPathoccurs during a
Path.samefile, it attempts to stat both files. This is theTargetPathand the stringy path. However, when it attempts to stat theTargetPathit misses the_accessorthat is used insideTargetPath*Note* This is also an issue when using
TargetPath.samefile(TargetPath) -
python3.10 When calling
samefilewith a string path it attempts to stat the string path withself._accessor.stat('/str/of/path'). However, in thestatofTargetPath3.10 it assumes the path passed is aTargetPathobject. Then it attempts to use agetcall on the string which doesn't exist -
python3.11 When calling
samefileon python 3.11 we get the following error:TypeError: invalid PureDissectPath initialization: missing filesystem, got ('/vmfs/volumes/a8904c52-004e297f-9598-eb765dc56934',) (this might be a bug, please report)
In this case samefile attempts to create a new
PureDissectPathclass. During this process it runsPureDissectPath._from_partswhere it expects the first argument to be aFilesystembut instead it receives the string path, and it crashes.
Didn't find an issue with python 3.12 or python 3.13