Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

barneygale
Copy link
Contributor

@barneygalebarneygale commentedMay 15, 2021
edited by bedevere-bot
Loading

This method is important and cannot be replaced withresolve()!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 withos.path methods. 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() butwithout 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

@kalvdans
Copy link

Documentation is clear and the suggested changes looks sane to me. Will take another look after windows test failures are addressed.

@barneygale
Copy link
ContributorAuthor

Tested are fixed, thanks for taking a look.

Copy link

@kalvdanskalvdans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Some small remarks.

@barneygale
Copy link
ContributorAuthor

barneygale commentedMay 16, 2021
edited
Loading

Note that this can't be automatically backported, as the tests' patching ofgetcwd() is different in 3.9 and below.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actionsgithub-actionsbot added the staleStale PR or inactive for long period of time. labelJul 15, 2021
Copy link
Member

@brettcannonbrettcannon left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

One clarifying doc change as suggested by@domdfcoding. A news entry is also missing.

@bedevere-bot
Copy link

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 phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@github-actionsgithub-actionsbot removed the staleStale PR or inactive for long period of time. labelJul 17, 2021
@barneygale
Copy link
ContributorAuthor

Sorry for the long delay. Does this need a NEWS entry? It adds docs and tests but doesn't change the implementation ofPath.absolute()

@barneygalebarneygaleforce-pushed thebpo-29688-pathlib-absolute-docs-tests branch from644703a to64204fdCompareJanuary 1, 2022 01:21
@brettcannon
Copy link
Member

Sorry for the long delay. Does this need a NEWS entry? It adds docs and tests but doesn't change the implementation ofPath.absolute()

It looks like you added a news entry anyway. 😄

Copy link
Member

@brettcannonbrettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Question about the docs and some very minor formatting things.

Comment on lines +2662 to +2670
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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
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
Copy link
Member

Thanks,@barneygale !

@barneygale
Copy link
ContributorAuthor

Thanks very much for the review!

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

@brianhelbabrianhelbabrianhelba left review comments

@eamanueamanueamanu left review comments

@domdfcodingdomdfcodingdomdfcoding left review comments

@brettcannonbrettcannonbrettcannon approved these changes

@kalvdanskalvdanskalvdans approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

8 participants
@barneygale@kalvdans@bedevere-bot@brettcannon@brianhelba@eamanu@domdfcoding@the-knights-who-say-ni

[8]ページ先頭

©2009-2025 Movatter.jp