You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 83fd880
Browse filesBrowse the repository at this point in the historyBrowse files
Raise TypeError instead of recursing on unsupported operator directions
PyType_Ready adds a slot wrapper for the forward and the reflected method
of each number slot FixupSlots sets, when the type dict lacks them. A type
declaring an operator in one direction only, like x + x, got a __radd__
wrapper that calls the very slot that dispatched to it, so 1.0 + x,
1 + x or sum([x]) recursed until RecursionError instead of raising
TypeError. The same happened with [Flags] enums, whose bitwise operators
are forward only (1 & flags).
The wrappers without a CLR operator behind them are now removed after
PyType_Ready, so the slot returns NotImplemented and Python raises its
usual TypeError. A Python subclass can still define the missing method.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,6 +92,7 @@ Instead, `PyIterable` does that.
92
92
93
93
### Fixed
94
94
95
+
- An operation a type supports in one direction only, like `1.0 + x` when `x` only declares `x + x`, raises `TypeError` instead of recursing until `RecursionError`
95
96
- Fix incorrect dereference of wrapper object in `tp_repr`, which may result in a program crash
96
97
- Fixed parameterless .NET constructor being silently called when a matching constructor overload is not found ([#238][i238])
97
98
- Fix incorrect dereference in params array handling
0 commit comments