Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix windows file links in RichHandler using Path.as_uri() - #4140

Open
VectorSophie wants to merge 1 commit into
Textualize:mainfrom
VectorSophie:fix/windows-file-links
Open

VectorSophie wants to merge 1 commit into
Textualize:mainfrom
VectorSophie:fix/windows-file-links

Conversation

@VectorSophie

Copy link
Copy Markdown

Fixes #4093

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Textualize Textualize temporarily blocked VectorSophie May 22, 2026
@sathwiksgjois

Copy link
Copy Markdown

Hi, I tried to open a PR but GitHub says PRs are restricted to collaborators.
Could you allow fork PRs or guide me on how to contribute?

@UnderHear UnderHear left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AI-assisted source review by dot; I have not run the tests.

At c2250b5, the new test_link_path_uri_format has contradictory assertions on POSIX when the checkout path contains no characters requiring URI escaping. For example, if abs_path is /tmp/rich/tests/test_logging.py, both Path(abs_path).as_uri() and "file://" + abs_path are file:///tmp/rich/tests/test_logging.py. Line 147 requires that URI to occur in link_styles, while line 150 forbids the identical string, so the test rejects the correct POSIX result.

Could the negative assertion be restricted to the malformed Windows case, or replaced with exact assertions on the filename and line-number links against Path(abs_path).as_uri() and its #1 form? A Linux/macOS checkout with a plain path would exercise this contradiction.

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Resolve relative log paths before calling as_uri()

In rich/_log_render.py, Path(link_path).as_uri() raises ValueError for a relative path. RichHandler.render() passes record.pathname through as link_path, and a LogRecord can have a relative pathname (for example, code compiled with a relative filename or a manually constructed record). Rendering happens before emit() enters its print error handler, so one such log call now raises instead of logging. Could this resolve the path to an absolute path before as_uri() (or retain a safe fallback), and cover a relative link_path in a test?

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.

[BUG] rich.logging.RichHandler: File links on Windows (VS Code) use incorrect format (file:// instead of file:/// and backslashes)

4 participants