Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
zooba merged 1 commit intopython:masterfrombarneygale:bpo-39906-pathlib-path-follow-symlinksApr 7, 2021
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
19 changes: 16 additions & 3 deletionsDoc/library/pathlib.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -713,11 +713,14 @@ call fails (for example because the path doesn't exist). | ||
.. versionadded:: 3.5 | ||
.. method:: Path.stat(*, follow_symlinks=True) | ||
Return a :class:`os.stat_result` object containing information about this path, like :func:`os.stat`. | ||
The result is looked up at each call to this method. | ||
This method normally follows symlinks; to stat a symlink add the argument | ||
``follow_symlinks=False``, or use :meth:`~Path.lstat`. | ||
:: | ||
>>> p = Path('setup.py') | ||
@@ -726,10 +729,18 @@ call fails (for example because the path doesn't exist). | ||
>>> p.stat().st_mtime | ||
1327883547.852554 | ||
.. versionchanged:: 3.10 | ||
barneygale marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
The *follow_symlinks* parameter was added. | ||
.. method:: Path.chmod(mode, *, follow_symlinks=True) | ||
Change the file mode and permissions, like :func:`os.chmod`. | ||
This method normally follows symlinks. Some Unix flavours support changing | ||
permissions on the symlink itself; on these platforms you may add the | ||
argument ``follow_symlinks=False``, or use :meth:`~Path.lchmod`. | ||
:: | ||
>>> p = Path('setup.py') | ||
>>> p.stat().st_mode | ||
@@ -738,6 +749,8 @@ call fails (for example because the path doesn't exist). | ||
>>> p.stat().st_mode | ||
33060 | ||
.. versionchanged:: 3.10 | ||
barneygale marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
The *follow_symlinks* parameter was added. | ||
.. method:: Path.exists() | ||
20 changes: 6 additions & 14 deletionsLib/pathlib.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletionsLib/test/test_pathlib.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsMisc/NEWS.d/next/Library/2020-03-30-00-13-27.bpo-39906.eaR3fN.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:meth:`pathlib.Path.stat` and :meth:`~pathlib.Path.chmod` now accept a *follow_symlinks* keyword-only argument for consistency with corresponding functions in the :mod:`os` module. |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.