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.
Created on 2012年10月11日 13:10 by exarkun, last changed 2022年04月11日 14:57 by admin.
| Messages (3) | |||
|---|---|---|---|
| msg172639 - (view) | Author: Jean-Paul Calderone (exarkun) * (Python committer) | Date: 2012年10月11日 13:10 | |
There appears to be very little, if any, documentation about how to handle the list at tp_weaklistoffset for types supporting being weak referenced, particularly with respect to garbage collection. Who owns the list? Who owns the objects in the list? Should the list be traversed by the extension type's tp_traverse? Should it ever be INCREF'd or DECREF'd? Does tp_dealloc have any responsibilities with respect to it? From looking at CPython's own source, it appears that tp_traverse should not touch it (Yhg1s confirmed this on #python). Cython, at least, appears to have come to an alternate conclusion though - it generates tp_traverse functions which visit the list (and provoke gc assertions to fail on Python 2.7 in debug mode). Some documentation about what is correct to do would be excellent, and would make it easier to explain to Cython developers what they're doing wrong (or confirm that they're doing something right, in which case there are some more bugs to file against the CPython stdlib, since they do something different from Cython). |
|||
| msg172641 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2012年10月11日 13:22 | |
I think Cython is wrong here. The only thing to do is to call PyObject_ClearWeakRefs() in the deallocator. Everything else is handled by the interpreter. Agreed improving the documentation would be good. |
|||
| msg198983 - (view) | Author: Stefan Behnel (scoder) * (Python committer) | Date: 2013年10月05日 09:56 | |
Just as a quick update here: Cython has since then switched to only using PyObject_ClearWeakRefs() and otherwise leaves the handling of the weakref slot to CPython. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:37 | admin | set | github: 60399 |
| 2013年10月05日 09:56:16 | scoder | set | messages: + msg198983 |
| 2013年10月04日 20:05:41 | pconnell | set | nosy:
+ pconnell |
| 2012年10月19日 19:31:35 | jcea | set | nosy:
+ jcea |
| 2012年10月11日 13:22:12 | pitrou | set | versions:
+ Python 2.7, Python 3.2, Python 3.3, Python 3.4 nosy: + pitrou, scoder messages: + msg172641 type: behavior stage: needs patch |
| 2012年10月11日 13:19:07 | asvetlov | set | nosy:
+ asvetlov |
| 2012年10月11日 13:10:21 | exarkun | create | |