-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
First off, I love the work you did with forbiddenfruit, it's been super useful!
I have encountered an issue while trying to monkey-patch rich comparison dunder methods (like __le__) on built-in types such as list, int, float, dict, and set.
Basically, when attempting to curse list.__le__, I receive a KeyError: '__le__' at _curse_special (specifically override_dict[attr]).
# Test code
from forbiddenfruit import curse
original___le__ = list.__le__
def custom___le__(self, other):
print("custom___le__ called!")
return original___le__(self, other)
curse(list, '__le__', custom___le__)
a = [1]; b = [2]
print(a <= b)
# Traceback observed:
# File ".../forbiddenfruit/__init__.py", line 334, in _curse_special
# tp_as_name, impl_method = override_dict[attr]
# KeyError: '__le__'Looking at the source code, I noticed this comment "# Type not declared yet"
forbiddenfruit/forbiddenfruit/__init__.py
Line 215 in e225192
| ('tp_richcompare', ctypes.c_void_p), # Type not declared yet |
Does that mean it is possible to support this functionality, but it is not currently implemented?
Note: I'm using Python 3.12.8
Metadata
Metadata
Assignees
Labels
No labels