Skip to content

Conversation

@love1120520
Copy link

@love1120520 love1120520 commented Nov 28, 2025

[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:

go-NNNNNN: Summary of the changes made

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:

[X.Y] <title from the original PR> (GH-NNNNNN)

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/

Copy link

Copilot AI left a 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 strict parameter to os.path.realpath() in both POSIX and Windows implementations
  • Refactored pathlib.Path.resolve() to use os.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.

@StanFromIreland StanFromIreland changed the title Pr/25264 Spam Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants