| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
A sign, a space or an alternate form parsed fine on a string spec and
then had no effect:
>>> format('ab', '+')
'ab'
>>> f"{'ab':RustPython#5}"
'ab '
CPython raises ValueError for all three. format_string already refused z
and an explicit '=' alignment with the same family of messages, so the
three checks go next to those, in the order CPython reports them: sign,
then z, then the alternate form, then the alignment.
Assisted-by: Claude Code:claude-opus-5
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 2f30f721-6552-47b3-bc66-beed14c32630 📥 CommitsReviewing files that changed from the base of the PR and between 3d2ee64 and c9da10d. 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 Walkthrough WalkthroughString formatting now rejects unsupported sign and alternate-form flags for strings. The formatter reports errors in CPython precedence order, the VM maps them to ValueError, and unit and regression tests verify the error variants and messages. ChangesString format validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to c9da1 This localized change makes string formatting reject flags that CPython rejects, with tests and checks reported passing; no actionable merge-blocking risk remains. Suggested reviewers: shaharnaveh, shan-kor, youknowone 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
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. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
A sign, a space or an alternate form in a string format spec is accepted and then dropped:
format_string in crates/common/src/format.rs already turns down z and an explicit = alignment for strings, with the wording CPython uses. These three were never checked, so the spec parses, the flag means nothing to a string, and the caller gets plain padding where CPython refuses the spec outright.
The three checks sit next to the two that were already there. Their order is the one CPython reports in, which I read off these, under CPython 3.14:
FormatSpecError gains one variant that carries the flag name, so the three share a message built the same way as StringAlignmentFlag.
Tests
I ran the string spec shapes side by side under CPython 3.14 and this build: the four flags, fill and align pairs, width, precision, grouping, the format codes, and specs where two errors compete. Two differences are left afterwards, neither on this path. Invalid format specifier is still missing the spec and the type, which #8477 covers. And format('ab', '+,5') reports the unknown format code here while CPython reports the grouping.
test_str.test_format asserts all three, but its marker records an unrelated reason to stay an expected failure ('{0.}'.format() raises ValueError instead of IndexError), so the snippet carries the coverage instead.
AI assistance
Claude Code (claude-opus-5) helped with the comparison against CPython, the change and this description. I read the final diff and ran the checks above on Linux.
Summary by CodeRabbit
Bug Fixes
Tests