This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author esoma
Recipients andribas404, esoma
Date 2021-02-24.16:16:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614183381.48.0.0601937390902.issue43310@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-02-24 16:16:21esomasetrecipients: + esoma, andribas404
2021-02-24 16:16:21esomasetmessageid: <1614183381.48.0.0601937390902.issue43310@roundup.psfhosted.org>
2021-02-24 16:16:21esomalinkissue43310 messages
2021-02-24 16:16:21esomacreate