Skip to content

bpo-29688: document and test pathlib.Path.absolute(). - #26153

Merged
brettcannon merged 9 commits into
python:mainfrom
barneygale:bpo-29688-pathlib-absolute-docs-tests
Jan 28, 2022
Merged

brettcannon merged 9 commits into
python:mainfrom
barneygale:bpo-29688-pathlib-absolute-docs-tests

Conversation

@barneygale

@barneygale barneygale commented May 15, 2021 •

Copy link
Copy Markdown
Contributor

This method is important and cannot be replaced with resolve()! resolve() will hit OS APIs to resolve symlinks/etc, and will fail on symlink loops, whereas absolute() just prepends the working directory and can never raise an OSError.

Also improved the table showing correspondence with os.path methods. The gory details:

  • Path.resolve() is os.path.realpath() in strict mode, with a tweaked exception type for symlink loops (backwards compat)
  • Path.absolute() is os.path.abspath() but without normalizing the path. The pathlib behaviour is better, as abspath()'s normlisation changes the meaning of the path in the presence of symlinks!

Happy to expand the tests if anyone has any ideas what else to cover.

https://bugs.python.org/issue29688

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants