Skip to content

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Jan 20, 2026

This PR is made by CI by accident. Try not to allow it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This PR introduces three new bytecode instructions (DictMerge, ListExtend, SetUpdate) with corresponding VM frame handlers and compiler codegen support. Additionally, it adds stdlib directory path tracking throughout the VM's runtime configuration and sys module, refactors collection construction in the code generator to optimize starred/unstarred elements via threshold-based branching, and improves Windows path resolution robustness.

Changes

Cohort / File(s) Summary
Configuration & Metadata
.cspell.dict/cpython.txt, .gitattributes, crates/vm/src/vm/setting.rs
Added three spell-check dictionary entries (kwnames, nkwelts, subkwargs), configured test resource attributes in git for importlib and email test data with binary/CRLF settings, and added new stdlib_dir: Option<String> field to Paths struct.
Compiler Codegen
crates/codegen/src/compile.rs
Reworked collection construction with threshold-based branching to choose between fast single-build path (no stars, small collections) and streaming path (stars or large sizes). Introduced new codegen_subkwargs helper for efficient keyword argument emission, and updated call/class building to support the new strategies with improved MapAdd handling.
Bytecode Instruction Definitions
crates/compiler-core/src/bytecode/instruction.rs
Updated stack effects for three instructions: DictMerge, ListExtend, and SetUpdate now have stack effect -1 (previously 0), reflecting the operations' consumption of values during execution.
VM Frame Execution
crates/vm/src/frame.rs
Added three new instruction handlers (DictMerge, ListExtend, SetUpdate) with validation and type checking; DictMerge enforces string keys and detects duplicates, while ListExtend and SetUpdate safely downcast and extend/update collections. Extended BuildList with intermediate size variable and renamed indexing variables (i → idx) in LoadDeref and LoadFromDictOrDeref.
Path Configuration & Initialization
crates/vm/src/getpath.rs, crates/vm/src/stdlib/sys.rs, src/interpreter.rs
Added new calculate_stdlib_dir function to compute platform-specific stdlib paths, exposed _stdlib_dir attribute in sys module, and refactored interpreter setup to move stdlib_dir configuration from sys module hacks to centralized state-based initialization for both frozen and dynamic stdlib scenarios.
Windows Build Path Handling
crates/pylib/build.rs
Rewrote Windows Lib path resolution to handle two cases: text files containing relative paths and symlinks/directories, with proper canonicalization and extended-length prefix stripping for robustness in Git-enabled environments.

Sequence Diagram(s)

sequenceDiagram
    participant Compiler as Compiler<br/>(codegen)
    participant Codegen as Codegen Helper<br/>(codegen_subkwargs)
    participant Bytecode as Bytecode<br/>(DictMerge instr)
    participant VM as VM Frame<br/>(Execution)
    participant Dict as Target Dict

    Compiler->>Codegen: compile dict merge<br/>with **kwargs
    Codegen->>Codegen: choose fast or<br/>streaming path
    alt Streaming Path (stars present)
        Codegen->>Codegen: emit MapAdd ops
    else Fast Path (no stars)
        Codegen->>Codegen: build single map
    end
    Codegen->>Bytecode: emit DictMerge<br/>{index}
    Bytecode->>Bytecode: stack effect: -1
    VM->>VM: execute DictMerge
    VM->>VM: validate source<br/>is mapping
    VM->>Dict: iterate keys & merge<br/>with validation
    VM-->>VM: return Ok(None)<br/>on success
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • ShaharNaveh

Poem

🐰 A hop through bytecode, paths aligned!
DictMerge, ListExtend, SetUpdate designed,
Stdlib paths now tracked with care,
Fast paths chosen, streaming paths fair,
Windows paths robust, no more despair! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'Prohibit AI PR submit' is unrelated to the changeset, which contains CI fixes, opcode changes, stdlib_dir configuration, and keyword argument handling optimizations. Update the title to reflect the actual changes, such as 'Fix CI test failures from PR 6798' or 'Add stdlib_dir support and fix CI test failures'.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@youknowone youknowone marked this pull request as draft January 20, 2026 08:54
@youknowone youknowone changed the title Fix CI test failures from PR 6798 Prohibit AI PR submit Jan 20, 2026
@youknowone youknowone added the skip:ci Skip running the ci label Jan 20, 2026
@youknowone youknowone marked this pull request as ready for review January 20, 2026 12:12
@youknowone youknowone merged commit 94ccfb8 into RustPython:main Jan 20, 2026
9 checks passed
@youknowone youknowone deleted the stdlib_dir branch January 20, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip:ci Skip running the ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant