Fix __set_name__ error handling to match Python 3.12+ - #6937
Conversation
📝 WalkthroughWalkthroughModified error handling in type initialization by replacing error wrapping with best-effort note augmentation. Instead of creating a new runtime error with the original as cause, the code now uses Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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 |
|
Code has been automatically formatted The code in this PR has been formatted using:
git pull origin set_name_error |
9a8fcf3 to
bc9a8d4
Compare
Changed type.rs to add notes to original exceptions instead of wrapping them in RuntimeError, following PEP 678 (gh-77757). This allows enum.py's exception handling to work correctly when super().__new__() is misused in Enum subclasses, enabling the proper TypeError to propagate instead of being hidden behind a RuntimeError wrapper. Fixes test_bad_new_super test case.
bc9a8d4 to
7f06b96
Compare
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/enum.py dependencies:
dependent tests: (10 tests)
[x] lib: cpython/Lib/functools.py dependencies:
dependent tests: (37 tests)
[ ] test: cpython/Lib/test/test_class.py (TODO: 16) dependencies: dependent tests: (no tests depend on class) Legend:
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Changed type.rs to add notes to original exceptions instead of wrapping them in RuntimeError, following PEP 678 (gh-77757).
This allows enum.py's exception handling to work correctly when super().new() is misused in Enum subclasses, enabling the proper TypeError to propagate instead of being hidden behind a RuntimeError wrapper.
Fixes test_bad_new_super test case.
Summary by CodeRabbit
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.