Rev 173: Walk to the child and parent lists last, and ensure that we actually do so. in http://bazaar.launchpad.net/~meliae-dev/meliae/trunk

John Arbash Meinel john at arbash-meinel.com
Thu Jul 29 22:34:15 BST 2010


At http://bazaar.launchpad.net/~meliae-dev/meliae/trunk

------------------------------------------------------------
revno: 173
revision-id: john at arbash-meinel.com-20100729213354-hilj24gphuriqdpx
parent: john at arbash-meinel.com-20100729212917-lc6ejysiyr3qvnq3
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Thu 2010-07-29 16:33:54 -0500
message:
  Walk to the child and parent lists last, and ensure that we actually do so.
-------------- next part --------------
=== modified file 'meliae/_loader.pyx'
--- a/meliae/_loader.pyx	2010-07-29 21:29:17 +0000
+++ b/meliae/_loader.pyx	2010-07-29 21:33:54 +0000
@@ -1092,11 +1092,11 @@
         ret = visit(self.address, arg)
     if ret == 0 and self.type_str != NULL:
         ret = visit(self.type_str, arg)
+    if ret == 0 and self.value != NULL:
+        ret = visit(self.value, arg)
     if ret == 0:
         # RefList_traverse handles the NULL case
         ret = RefList_traverse(self.child_list, visit, arg)
-    if ret == 0 and self.value != NULL:
-        ret = visit(self.value, arg)
     if ret == 0:
         ret = RefList_traverse(self.parent_list, visit, arg)
     # Note: we *don't* incref the proxy because we know it links back to us. So

=== modified file 'meliae/tests/test__loader.py'
--- a/meliae/tests/test__loader.py	2010-07-29 21:29:17 +0000
+++ b/meliae/tests/test__loader.py	2010-07-29 21:33:54 +0000
@@ -540,14 +540,23 @@
         # When a Proxied object is removed from its Collection, it becomes
         # owned by the Proxy itself, and should be returned from tp_traverse
         mop = self.moc[0]
-        referenced = _scanner.get_referents(mop)
         # At this point, moc still controls the _MemObject
-        self.assertEqual([self.moc], referenced)
+        self.assertEqual([self.moc], _scanner.get_referents(mop))
         # But now, it references everything else, too
         del self.moc[0]
-        referenced = _scanner.get_referents(mop)
         self.assertEqual([self.moc, mop.address, mop.type_str, mop.value],
-                         referenced)
+                         _scanner.get_referents(mop))
+
+    def test_traverse_with_parent_and_children(self):
+        mop = self.moc.add(1, 'my_class', 1234, children=[5,6,7],
+                           parent_list=[8,9,10], value='test str')
+        # While in the moc, the Collection manages the references
+        self.assertEqual([self.moc], _scanner.get_referents(mop))
+        # But once gone, we refer to everything directly
+        del self.moc[1]
+        self.assertEqual([self.moc, mop.address, mop.type_str, mop.value,
+                          5, 6, 7, 8, 9, 10],
+                         _scanner.get_referents(mop))
 
 
 class Test_MemObjectProxyIterRecursiveRefs(tests.TestCase):



More information about the bazaar-commits mailing list