Uh oh!
There was an error while loading. Please reload this page.
bpo-29688: document and test pathlib.Path.absolute(). - #26153
Conversation
kalvdans
commented
May 16, 2021
Documentation is clear and the suggested changes looks sane to me. Will take another look after windows test failures are addressed. |
barneygale
commented
May 16, 2021
Tested are fixed, thanks for taking a look. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Note that this can't be automatically backported, as the tests' patching of |
Uh oh!
There was an error while loading. Please reload this page.
This PR is stale because it has been open for 30 days with no activity. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
One clarifying doc change as suggested by @domdfcoding. A news entry is also missing.
Uh oh!
There was an error while loading. Please reload this page.
bedevere-bot
commented
Jul 16, 2021
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Uh oh!
There was an error while loading. Please reload this page.
barneygale
commented
Jan 1, 2022
Sorry for the long delay. Does this need a NEWS entry? It adds docs and tests but doesn't change the implementation of |
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Brian Helba <brian.helba@kitware.com>
644703a to
64204fdComparebrettcannon
commented
Jan 7, 2022
It looks like you added a news entry anyway. 😄 |
brettcannon
left a comment
There was a problem hiding this comment.
Question about the docs and some very minor formatting things.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Brett Cannon <brett@python.org>
| self.assertEqual(str(P('c:\\').absolute()), 'c:\\') | ||
| self.assertEqual(str(P('c:\\a').absolute()), 'c:\\a') | ||
| self.assertEqual(str(P('c:\\a\\b').absolute()), 'c:\\a\\b') | ||
| # UNC absolute paths. | ||
| share = '\\\\server\\share\\' | ||
| self.assertEqual(str(P(share).absolute()), share) | ||
| self.assertEqual(str(P(share + 'a').absolute()), share + 'a') | ||
| self.assertEqual(str(P(share + 'a\\b').absolute()), share + 'a\\b') |
There was a problem hiding this comment.
| self.assertEqual(str(P('c:\\').absolute()), 'c:\\') | |
| self.assertEqual(str(P('c:\\a').absolute()), 'c:\\a') | |
| self.assertEqual(str(P('c:\\a\\b').absolute()), 'c:\\a\\b') | |
| # UNC absolute paths. | |
| share='\\\\server\\share\\' | |
| self.assertEqual(str(P(share).absolute()), share) | |
| self.assertEqual(str(P(share+'a').absolute()), share+'a') | |
| self.assertEqual(str(P(share+'a\\b').absolute()), share+'a\\b') | |
| self.assertEqual(str(P(r'c:\').absolute()), r'c:\') | |
| self.assertEqual(str(P(r'c:\a').absolute()), r'c:\a') | |
| self.assertEqual(str(P(r'c:\a\b').absolute()), r'c:\a\b') | |
| # UNC absolute paths. | |
| share='\\\\server\\share\\' | |
| self.assertEqual(str(P(share).absolute()), share) | |
| self.assertEqual(str(P(share+'a').absolute()), share+'a') | |
| self.assertEqual(str(P(share+r'a\b').absolute()), share+r'a\b') |
brettcannon
commented
Jan 28, 2022
Thanks, @barneygale ! |
barneygale
commented
Jan 29, 2022
Thanks very much for the review! |
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, whereasabsolute()just prepends the working directory and can never raise an OSError.Also improved the table showing correspondence with
os.pathmethods. The gory details:Path.resolve()isos.path.realpath()in strict mode, with a tweaked exception type for symlink loops (backwards compat)Path.absolute()isos.path.abspath()but without normalizing the path. The pathlib behaviour is better, asabspath()'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