Skip to content

Align REG_MULTI_SZ input encoding with CPython - #9604

Merged
youknowone merged 3 commits into
RustPython:mainfrom
youknowdot:fix/winreg-multisz-encoding-20261103
Nov 5, 2026
Merged

youknowone merged 3 commits into
RustPython:mainfrom
youknowdot:fix/winreg-multisz-encoding-20261103

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Align the REG_MULTI_SZ input conversion with CPython 3.15:

  • Preserve embedded and trailing NUL code units in list items rather than rejecting them.
  • Encode None as the same two-byte empty multi-string used by CPython and by an empty list.
  • Validate all list items before growing the output buffer, then encode into one growable byte buffer without per-item wide-string temporaries.

Existing error types/messages for invalid items and very large-value overflow behavior are not addressed; this does not claim complete winreg parity.

Validation

  • Independently source-reviewed against CPython v3.15.0 PC/winreg.c; a CPython-only PyUnicode_AsWideChar probe confirmed copying of embedded/trailing NULs.
  • prek hooks and git diff --check passed.
  • No RustPython compilation or Windows execution was run locally; CI is needed.

Summary by CodeRabbit

  • Bug Fixes
    • Registry multi-string values now encode None and empty lists with a single UTF-16 NUL terminator; previously, empty lists used two.
    • Lists are checked to ensure every item is a string before encoding.
    • Strings containing embedded NUL characters are now permitted in registry multi-string values.
    • Each string item is encoded as UTF-16LE and terminated with a NUL character.

Preserve embedded NULs, encode None as the empty multi-string, and validate all items before building one output buffer.

Assisted-by: dot:frontier-intelligence
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The REG_MULTI_SZ conversion changes how it encodes None and string lists. It validates that list items are strings, adds UTF-16 NUL terminators, and permits interior NULs in strings.

Changes: REG_MULTI_SZ encoding

Layer / File(s) Summary
Encode REG_MULTI_SZ inputs
crates/vm/src/stdlib/winreg.rs
None encodes as one UTF-16 NUL. List items are type-checked before encoding. Each string gets a terminator, followed by a final terminator. An empty list encodes as one NUL. Strings with interior NULs are no longer rejected.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related issues

  • RustPython issue 6839: The issue concerns standard-library updates against the CPython 3.15 baseline. This change updates winreg REG_MULTI_SZ input conversion to match that baseline.

Suggested reviewers: youknowone

Merge Risk: Minimal · up to 98a6c

The encoding change has no identified merge-blocking defect. Merge after normal Windows build and test checks pass.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: aligning REG_MULTI_SZ input encoding with CPython.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 729c8a3 and 98a6c86.

Files selected for processing: 1
  • crates/vm/src/stdlib/winreg.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@youknowone
youknowone marked this pull request as ready for review November 3, 2026 19:03
@youknowone
youknowone enabled auto-merge (squash) November 3, 2026 19:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T19:06:56.315138Z 6957101 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

The REG_MULTI_SZ encoding update removed the final to_wide_cstring call. Remove its obsolete trait import to fix Windows Clippy.

Assisted-by: dot:frontier-intelligence
auto-merge was automatically disabled November 3, 2026 22:40

Head branch was pushed to by a user without write access

Assisted-by: dot:frontier-intelligence
@youknowone
youknowone merged commit 3edd244 into RustPython:main Nov 5, 2026
24 of 28 checks passed
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.

2 participants