[issue21039] pathlib strips trailing slash

Isaac Schwabacher report at bugs.python.org
Tue Aug 5 23:10:11 CEST 2014


Isaac Schwabacher added the comment:

This may be only syntactic sugar, but it is POSIX-specified syntactic sugar: according to http://pubs.opengroup.org/onlinepubs/9699919799/. trailing slashes in pathnames are semantically meaningful in pathname resolution.  Tilde escapes are not mentioned.

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. [...]

----------
nosy: +ischwabacher

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21039>
_______________________________________


More information about the Python-bugs-list mailing list