Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue24373

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Use traverse & finalize in xxlimited and in PEP 489 tests
Type:behaviorStage:resolved
Components:Extension ModulesVersions:Python 3.6, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: ncoghlan, petr.viktorin, python-dev, serhiy.storchaka
Priority:normalKeywords:patch

Created on2015-06-03 13:21 bypetr.viktorin, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
xxlimited-finalize.patchpetr.viktorin,2015-06-03 13:21
Messages (5)
msg244743 -(view)Author: Petr Viktorin (petr.viktorin)*(Python committer)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)*(Python committer)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)*(Python committer)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)(Python triager)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)*(Python committer)Date: 2018-05-25 08:53
tp_finalize handlers should return "void". Seeissue33644.
History
DateUserActionArgs
2022-04-11 14:58:17adminsetgithub: 68561
2018-05-25 08:53:50serhiy.storchakasetnosy: +serhiy.storchaka
messages: +msg317663
2015-06-04 12:58:45ncoghlansetstatus: open -> closed
type: behavior
resolution: fixed
stage: resolved
2015-06-04 11:58:34python-devsetnosy: +python-dev
messages: +msg244813
2015-06-04 08:53:10petr.viktorinsetmessages: +msg244809
2015-06-04 08:00:38ncoghlansetmessages: +msg244807
2015-06-03 13:21:01petr.viktorincreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp