pathlib.Path currently strips trailing slashes from pathnames, but this behavior contradicts POSIX (http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_12), which specifies that the resolution of the pathname of a symbolic link to a directory in the context of a function that operates on symbolic links shall depend on whether the pathname has a trailing slash:
> 4.12 Pathname Resolution > ======================== > > [...] > > A pathname that contains at least one non- <slash> character and that ends > with one or more trailing <slash> characters shall not be resolved > successfully unless the last pathname component before the trailing <slash> > characters names an existing directory or a directory entry that is to be > created for a directory immediately after the pathname is resolved. > Interfaces using pathname resolution may specify additional constraints[1] > when a pathname that does not name an existing directory contains at least > one non- <slash> character and contains one or more trailing <slash> > characters. > > If a symbolic link is encountered during pathname resolution, the behavior > shall depend on whether the pathname component is at the end of the pathname > and on the function being performed. If all of the following are true, then > pathname resolution is complete: > > 1. This is the last pathname component of the pathname. > 2. The pathname has no trailing <slash>. > 3. The function is required to act on the symbolic link itself, or certain > arguments direct that the function act on the symbolic link itself. > > In all other cases, the system shall prefix the remaining pathname, if any, > with the contents of the symbolic link. [...] The following sentence appeared in an earlier version of POSIX (http://pubs.opengroup.org/onlinepubs/009604499/basedefs/xbd_chap04.html#tag_04_11) but has since been removed: > A pathname that contains at least one non-slash character and that ends with > one or more trailing slashes shall be resolved as if a single dot character ( > '.' ) were appended to the pathname. Is this important enough to preserve trailing slashes? - Isaac Schwabacher _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com