Message387628
You can wrap your callable in a regular function:
```
def hack_c():
c = C()
def _(*args, **kwargs):
return c(*args, **kwargs)
return _
A.__del__ = hack_c()
```
Or (untested) make your callable an extension type with Py_TPFLAGS_METHOD_DESCRIPTOR.
Or instead of monkey-patching __del__ make __del__ call it:
```
class A:
my_del = lambda *args, **kwargs: None
def __del__(self):
self.my_del(self)
A.my_del = C()
```
This doesn't just apply to __del__, other dunders exhibit this behavior as well. It is unintuitive, but I'm pretty sure it's not a bug. |
|
Date |
User |
Action |
Args |
2021-02-24 16:16:21 | esoma | set | recipients:
+ esoma, andribas404 |
2021-02-24 16:16:21 | esoma | set | messageid: <1614183381.48.0.0601937390902.issue43310@roundup.psfhosted.org> |
2021-02-24 16:16:21 | esoma | link | issue43310 messages |
2021-02-24 16:16:21 | esoma | create | |
|