fix sys path by youknowone · Pull Request #6537 · RustPython/RustPython
Warning
Rate limit exceeded
@youknowone has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 7 seconds before requesting another review.
⌛ How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.
We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work?
CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.
⛔ Files ignored due to path filters (1)
Lib/test/test_cmd_line_script.pyis excluded by!Lib/**
📒 Files selected for processing (2)
src/lib.rssrc/settings.rs
📝 Walkthrough
Walkthrough
The changes reorder sys.path[0] initialization in lib.rs to align with CPython's behavior: site import now precedes path setup, with per-mode conditional path0 computation. Additionally, settings.rs filters empty environment variable values before path splitting to prevent empty strings from propagating through PATH-like variables.
Changes
| Cohort / File(s) | Summary |
|---|---|
sys.path[0] initialization reordering src/lib.rs |
Reorders initialization sequence so site module imports before sys.path[0] configuration. Adds conditional path0 computation based on run_mode (Command/Repl → empty string; Module → cwd; Script/InstallPip → None). Inserts computed path into sys.path only when path0 is Some(...). |
Environment PATH filtering src/settings.rs |
Filters out empty environment variable values in get_paths before path splitting, preventing empty strings from accumulating in PATH-like variables. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- RustPython/RustPython#6461: Modifies sys.path[0] initialization in src/lib.rs with ordering changes and conditional empty string insertion logic.
Poem
🐰 Paths now sorted just like CPython's way,
Site comes first to clean the day,
Empty strings we cast aside,
Initialization flows with pride!
Hop, hop, hop—initialization's right! ✨
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'fix sys path' is directly related to the main changes in the PR, which reorder sys.path initialization and fix path configuration across different run modes. |
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.