
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2015-06-03 13:21 bypetr.viktorin, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| xxlimited-finalize.patch | petr.viktorin,2015-06-03 13:21 | |||
| Messages (5) | |||
|---|---|---|---|
| msg244743 -(view) | Author: Petr Viktorin (petr.viktorin)*![]() | Date: 2015-06-03 13:21 | |
The example object in the xxlimited module can be part of a reference loop (it can contain itself), so it needs GC and tp_traverse.The tp_dealloc hook was incorrect, and a correct version would be difficult to generalize for something more complicated than a example class (#16690; [0]). It's better to avoid dealloc and show off tp_finalize.Same for the class in _testmultiphase (PEP 489 tests), which is based on xxlimited. The incorrect dealloc is causing the reference leak mentioned in#24268.The Xxo object also wasn't actually added to the module.Here is a patch to fix these.[0]https://mail.python.org/pipermail/python-dev/2015-June/140422.html | |||
| msg244807 -(view) | Author: Alyssa Coghlan (ncoghlan)*![]() | Date: 2015-06-04 08:00 | |
Would it also be worth making at docs update to tp_dealloc, suggesting the use of tp_traverse/finalize?:https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_deallocAnd perhaps from PyType_FromSpec?https://docs.python.org/3/c-api/type.html?highlight=pytype_fromspec#c.PyType_FromSpec | |||
| msg244809 -(view) | Author: Petr Viktorin (petr.viktorin)*![]() | Date: 2015-06-04 08:53 | |
tp_traverse is completely orthogonal to tp_dealloc, it's needed to detect (and then break) reference cycles like: obj = xxlimited.Xxo() obj.foo = objAs for tp_finalize: yes, mentioning it in tp_dealloc docs would be good, but I'll need a bit more studying to understand the problem correctly. The cases fixed here are relatively simple; Antoine gives more complex ones in [0]. When I feel qualified to give advice, I'll change the docs. (And most likely, write a PEP to make things easier; some changes to classes will be needed anyway to makePEP 489 multi-phase init work nicely in all cases).But, I plan to focus my CPython time on documentingPEP 489 before diving in here. I thinkissue 16690 is a good place to track tp_dealloc docs changes.[0]https://mail.python.org/pipermail/python-dev/2015-June/140423.html | |||
| msg244813 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2015-06-04 11:58 | |
New changeset265eeb60443a by Nick Coghlan in branch '3.5':Issue#24373: EliminatePEP 489 test refleakshttps://hg.python.org/cpython/rev/265eeb60443aNew changesetf24cd8bc5250 by Nick Coghlan in branch 'default':Merge fix for issue#24373 from 3.5https://hg.python.org/cpython/rev/f24cd8bc5250 | |||
| msg317663 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2018-05-25 08:53 | |
tp_finalize handlers should return "void". Seeissue33644. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:17 | admin | set | github: 68561 |
| 2018-05-25 08:53:50 | serhiy.storchaka | set | nosy: +serhiy.storchaka messages: +msg317663 |
| 2015-06-04 12:58:45 | ncoghlan | set | status: open -> closed type: behavior resolution: fixed stage: resolved |
| 2015-06-04 11:58:34 | python-dev | set | nosy: +python-dev messages: +msg244813 |
| 2015-06-04 08:53:10 | petr.viktorin | set | messages: +msg244809 |
| 2015-06-04 08:00:38 | ncoghlan | set | messages: +msg244807 |
| 2015-06-03 13:21:01 | petr.viktorin | create | |