Issue #14 invalid

Abspath doesn't cut ".." from path name.

Konstantine Rybnikov avatarKonstantine Rybnikov created an issue

When you call os.abspath, it removes unneeded ".." from your path, so if you were in '/a/b/c' and you called os.abspath('/a/b/c/../'), you'd get '/a/b/'.

I think .absolute() on PosixPath should get the same behavior.

Comments (3)

  1. July Tikhonov

    The description of Path.absolute() method states that "This function works even if the path doesn't point to anything". So, this method must be purely lexical (except for using cwd). This means that it cannot resolve any '..' parts, because this can change the meaning of the path (in case of symbolic links presence). To correctly resolve '..' parts, you should use Path.resolve() method.

  2. Antoine Pitrou

    Thanks July. July is right, resolve() is the only method which will collapse ".." components. The reason is simple: if /tmp is a symlink to /var/tmp, then /tmp/../usr is not the same as /usr !

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.