Message187367
Adding Guido because this appears to be due to a longstanding difference between the handling of tp_del and most other slots
Specifically, the reason for the odd behaviour appears to be that generator objects define tp_del [1] (which is what the cyclic gc *really* looks for), but while defining __del__ in Python will populate tp_del in the type slots, defining tp_del directly in a builtin or extension type doesn't create an exposed __del__ at the Python level (there's no wrapper function identified in the slot definition).
So, at the very least, the fact that builtin and extension types can define tp_del without creating a visible __del__ method needs to be documented as a CPython implementation detail.
However, I'm not sure we actually have a good *reason* for tp_del failing to generate __del__ automatically - it's been that way since Guido implemented it [2], but Guido's comment in that commit message about not needing a wrapper because types written in C can't define tp_del is clearly no longer accurate.
[1] http://hg.python.org/cpython/file/2.7/Objects/genobject.c#l328
[2] http://hg.python.org/cpython/annotate/71dca7c76fa2/Objects/typeobject.c#3955 |
|
Date |
User |
Action |
Args |
2013-04-19 16:03:24 | ncoghlan | set | recipients:
+ ncoghlan, gvanrossum, amaury.forgeotdarc, vstinner, benjamin.peterson, docs@python, Anssi.Kääriäinen, isoschiz |
2013-04-19 16:03:24 | ncoghlan | set | messageid: <1366387404.87.0.542770090305.issue17468@psf.upfronthosting.co.za> |
2013-04-19 16:03:24 | ncoghlan | link | issue17468 messages |
2013-04-19 16:03:24 | ncoghlan | create | |
|