Pathlib: preserve trailing slash

Also, random note. The very next thread in my reading list is this one: ·stable diffusion keeps pointing to the wrong version of python and it seems that a trailing backslash caused Windows to interpret something as a directory instead of a file, so this doesn’t seem to be Unix-specific or anything.