Skip to content

bpo-39906: add follow_symlinks parameter to pathlib.Path.stat() and chmod() #18864

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Mar 9, 2020

Backwards-compatible change that makes this work:

import pathlib
p = pathlib.Path("/some/symlink")
assert p.stat(follow_symlinks=True) == p.stat()
assert p.stat(follow_symlinks=False) == p.lstat()

This brings pathlib in line with the newish follow_symlinks parameters in os functions, and arguably provides a more explicit (and nicer?) interface.

For consistency I've applied the same change to chmod(), though as far as I can tell, changing permissions on symlinks is only available on some BSDs (see bpo-7479)

https://bugs.python.org/issue39906

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@barneygale

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@barneygale barneygale force-pushed the bpo-39906-pathlib-path-follow-symlinks branch from a0720ed to 3ede281 Compare March 10, 2020 20:52
@barneygale barneygale force-pushed the bpo-39906-pathlib-path-follow-symlinks branch 2 times, most recently from 7782e14 to 7f5854a Compare March 30, 2020 01:25
pitrou
pitrou previously requested changes Apr 17, 2020
Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

The addition looks good on the principle. Two comments though. Also, you'll need to rebase / merge from master.

@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 phrase I 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.

@csabella
Copy link
Contributor

@barneygale, please address the review comments. Thank you!

@barneygale barneygale force-pushed the bpo-39906-pathlib-path-follow-symlinks branch from 7f5854a to e9b6598 Compare May 29, 2020 01:09
@barneygale
Copy link
Contributor Author

Rebased + docs versions fixed

@barneygale
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@pitrou: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from pitrou May 29, 2020 01:19
@russelldavis
Copy link
Contributor

This is great, thanks. Not sure whether it's out of scope for this PR, but it might also be nice to add the follow_symlinks param to some of the methods that call stat() internally, in particular is_file() and is_dir() (this would be consistent with those same methods on os.DirEntry).

@barneygale barneygale force-pushed the bpo-39906-pathlib-path-follow-symlinks branch from e9b6598 to 2cc9f3b Compare January 21, 2021 23:37
@barneygale
Copy link
Contributor Author

@pitrou bumping this one! Think it's ready for review if you have the time

Copy link
Member

@zooba zooba left a comment

Choose a reason for hiding this comment

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

Sorry for the slow reviews. This looks fine to me, except it'll land in 3.10, and so the docs need to be updated to reflect that.

@barneygale barneygale force-pushed the bpo-39906-pathlib-path-follow-symlinks branch from 2cc9f3b to 163742d Compare April 7, 2021 01:05
@barneygale
Copy link
Contributor Author

Thanks for the review - I've updated the .. versionchanged bits.

@zooba zooba dismissed pitrou’s stale review April 7, 2021 15:51

Changes have been made

@zooba
Copy link
Member

zooba commented Apr 7, 2021

Just an FYI @barneygale, we squash merge at the end, so there's no need to rebase and force push PRs (merging and regular push is fine). All it does is break the review history.

@zooba zooba merged commit abf9649 into python:master Apr 7, 2021
@barneygale
Copy link
Contributor Author

Just an FYI @barneygale, we squash merge at the end, so there's no need to rebase and force push PRs (merging and regular push is fine). All it does is break the review history.

Good to know, thank you.

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.

7 participants