Fix zero padding for string format specs by shAn-kor · Pull Request #8407 · RustPython/RustPython · GitHub
Skip to content

Fix zero padding for string format specs - #8407

Merged
youknowone merged 2 commits into
RustPython:mainfrom
shAn-kor:fix-str-zero-padding-format
Jul 29, 2026
Merged

Fix zero padding for string format specs#8407
youknowone merged 2 commits into
RustPython:mainfrom
shAn-kor:fix-str-zero-padding-format

Conversation

@shAn-kor

@shAn-kor shAn-kor commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves the {0:08s} portion of the existing TODO: RUSTPYTHON in test_str.test_format.

  • Treats the implicit 0 flag in string format specs as zero fill with string alignment semantics.
  • Rejects explicitly requested = alignment for strings with CPython's ValueError message.
  • Preserves integer zero-padding behavior.
  • Keeps the unrelated {0.} expected-failure reason in place.
  • Adds common-layer and interpreter-level regression coverage.

Tests

  • prek run --all-files
  • cargo clippy
  • cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher
  • cargo run --release -- -m test test_str
  • pytest -v in extra_tests using the RustPython binary

AI assistance

Codex (GPT-5) assisted with the CPython comparison, implementation, and regression-test drafting. I reviewed the final diff and verified the behavior locally. Both commits include Assisted-by: Codex:gpt-5.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown
Contributor

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good, thank you for catching this

@youknowone
youknowone merged commit bf4a2b1 into RustPython:main Jul 29, 2026
27 checks passed
@shAn-kor
shAn-kor deleted the fix-str-zero-padding-format branch July 29, 2026 21:48
@moreal moreal added the z-ca-2026 Tag to track Contribution Academy 2026 label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

z-ca-2026 Tag to track Contribution Academy 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants