-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Spam #142031
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
Spam #142031
Conversation
…s in a path Removes a pathlib-specific implementation of `realpath()` that's mostly copied from `ntpath` and `posixpath`.
… when a new `strict=True` keyword-only argument is passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a strict keyword-only parameter to os.path.realpath() to control error handling when encountering non-existent paths or symlink loops. When strict=True, OSError is raised for these conditions; when strict=False (default), the function behaves as before, resolving paths as far as possible.
Key changes:
- Added
strictparameter toos.path.realpath()in both POSIX and Windows implementations - Refactored
pathlib.Path.resolve()to useos.path.realpath()instead of custom resolution logic - Added comprehensive test coverage for strict mode behavior in both test suites
- Updated documentation with clear explanation of the new parameter
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Misc/NEWS.d/next/Library/2021-04-08-22-11-27.bpo-25264.b33fa0.rst | Adds release note documenting the new strict parameter |
| Lib/posixpath.py | Implements strict parameter in realpath() and _joinrealpath() helper; raises on errors when strict=True |
| Lib/ntpath.py | Implements strict parameter in Windows realpath(); delegates to strict or non-strict path resolution |
| Lib/pathlib.py | Refactors to use os.path.realpath() via accessor; removes custom Windows and POSIX resolve implementations; simplifies symlink loop detection |
| Lib/test/test_posixpath.py | Adds tests for strict mode with non-existent paths and symlink loops; updates existing test comments to clarify non-strict behavior |
| Lib/test/test_ntpath.py | Adds Windows-specific tests for strict mode; mirrors POSIX test coverage with platform-specific path separators |
| Doc/library/os.path.rst | Documents the new strict parameter with clear behavioral description and version change note |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
[Copilot is generating a summary⋯⋯]<!--
Thanks for your contribution!
Please read this comment in its entirety。 It's quite important.
Pull Request title
It should be in the following format:
Where: gh-NNNNNN refers to the GitHub issue number.
Most PRs will require an issue number. Trivial changes, like fixing a typo, do not need an issue.
Backport Pull Request title
If this is a backport PR (PR made against branches other than
main),please ensure that the PR title is in the following format:
Where: [X.Y] is the branch name, for example: [3.13].
GH-NNNNNN refers to the PR number from
main.-->
📚 Documentation preview 📚: https://cpython-previews--142031.org.readthedocs.build/