msg153784 - (view) |
Author: Martin v. Löwis (loewis) *  |
Date: 2012-02-20 16:26 |
The C implementation of xml.etree.ElementTree.Element needs to support cyclic GC. The attached script demonstrates the lack to support that: in 3.2, the script passes; in 3.3 (7697223df6df) it fails with an AssertionError as the cycle was not cleared. This is an incompatible change from 3.2. |
|
|
msg155991 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2012-03-16 04:54 |
Martin, why do you think it's important for Element to support this? After all, this is XML, not an arbitrary tree. As such, the children of Element can only be other elements, and attribute values should be strings. Anything else will result in errors when attempting to write that Element into a real XML file. Semantically it doesn't make sense for the value of an attribute to be a list or any other container, for that matter. In your sample code, if you attempt to dump or write L[0] before deleting it, you'll get an error. Adding GC handling complicates the code (even if not by too much), and this complication should be justified. Can you see a valid use case where GC handling would be required? |
|
|
msg156151 - (view) |
Author: Martin v. Löwis (loewis) *  |
Date: 2012-03-17 10:25 |
As a matter of principle, garbage collection in Python should *always* work, for all types, except for the one documented exception (cycles involving __del__). Failure of a type to properly garbage collect should be considered as serious as an interpreter crash; I hence propose this issue as release blocker. In addition, failure to support tp_traverse means that gc.get_referents doesn't work for the type, which is an inconvenience even in regular (non-cyclic) usage. |
|
|
msg156706 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2012-03-24 16:48 |
Find attached a patch. Added cyclic GC support to Element objects. Also added tests that verify that cycles involving Element objects are being collected. I'd really appreciate a review on this, since this is the first time I have to explicitly deal with cyclic GC from C extensions. |
|
|
msg157136 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2012-03-30 13:39 |
New changeset 0ca32013d77e by Eli Bendersky in branch 'default': Issue #14065: Added cyclic GC support to ET.Element http://hg.python.org/cpython/rev/0ca32013d77e |
|
|
msg157296 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2012-04-01 14:43 |
Re-opening, since GC collection of length-2 cycles cause refleaks (Issue #14464). For now the test was reverted in changeset c5cf48752d81 - it has to be put back when this is fixed. |
|
|
msg157439 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2012-04-03 19:04 |
New changeset 14abfa27ff19 by Eli Bendersky in branch 'default': Fixes and enhancements to _elementtree: http://hg.python.org/cpython/rev/14abfa27ff19 |
|
|
msg157448 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2012-04-03 23:45 |
Just in case you missed it: The Windows buildbots fail to compile 14abfa27ff19: http://www.python.org/dev/buildbot/all/builders/x86%20Windows7%203.x |
|
|
msg157459 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2012-04-04 04:57 |
Stefan, thanks. The windows bots were down when I was looking :-/ I'll work on a fix |
|
|
msg157460 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2012-04-04 05:13 |
Attaching a patch that should fix the build - I don't have write access to commit where I am - will be able to commit it later today. |
|
|
msg157475 - (view) |
Author: Eli Bendersky (eli.bendersky) *  |
Date: 2012-04-04 13:12 |
Fix committed - Windows bots now compile successfully. |
|
|