Fix error messages in binary/ternary ops to match CPython format#7625
Fix error messages in binary/ternary ops to match CPython format#7625youknowone merged 2 commits intoRustPython:mainfrom
Conversation
📝 WalkthroughWalkthroughAdjusted VM error-message formatting for a ternary operand type error to include the third operand's type and tweaked the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/fractions.py dependencies:
dependent tests: (65 tests)
Legend:
|
divmod error message to match CPython format
Fixes two closely-related error-message divergences in
crates/vm/src/vm/vm_ops.rs. Both affectTypeErrortext for arithmetic ops with unsupported operand types. Each unmasks one@unittest.expectedFailureintest_fractions.py.Fix 1 —
divmodmissing parenthesesSymptom.
divmod(x, y)with unsupported types emits"... for divmod: ...". CPython emits"... for divmod(): ..."(the function-call form, consistent with howpow()is named).Fix.
vm_ops.rs:404—"divmod"→"divmod()".Source. CPython's
Objects/abstract.cuses"divmod()"as the op_name for the divmod dispatch.Unmasks:
test_fractions.py::FractionTest::test_complex_handling.Fix 2 — ternary op error uses " and " instead of ", "
Symptom. 3-argument error (e.g.
pow(a, b, c)with unsupported types) emits"'X' and 'Y', 'Z'". CPython emits"'X', 'Y', 'Z'"— all commas.Fix.
vm_ops.rs:375— the format string's'{}' and '{}', '{}'→'{}', '{}', '{}'.The 2-argument case (line 367) correctly keeps
'X' and 'Y'(CPython matches this).Unmasks:
test_fractions.py::FractionTest::test_three_argument_pow.Verification