Fix pow() raising ValueError instead of TypeError for non-int exponent#7725
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe changes fix the validation order in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
|
I'm still fairly new to both Rust and RustPython, so I appreciate your patience. Please feel free to point out anything that could be improved in this request:) |
Welcome to the project 🥳 |
Description
Fixes #7724
pow(x, y, z)raisedValueErrorwhen the modulus was zero even if the exponent was a non-integer such asNoneorfloat, instead of falling through to theTypeErrorthat CPython raises.AS-IS
TO-BE
(matching CPython)
Changes
othertoPyIntfirst inPyInt::modpowand returnNotImplementedwhen the cast fails, soternary_opfalls through to the properTypeError— either the formatted "unsupported operand type(s)" message orPyFloat's "pow() 3rd argument not allowed unless all arguments are integers".extra_tests/snippets/builtin_pow.pycoveringpow(1, None, 0)andpow(True, 1.5, False).Summary by CodeRabbit
Release Notes
Bug Fixes
pow()function's 3-argument form to properly handle and reject incompatible argument types.Tests
pow()raisesTypeErrorfor incompatible argument types.