Whole file
caesar0301/treelib
The author described this change as “fix root removal in remove_subtree”. It counts as a record because the check below fails on the code as it stood at ad9985e70 and passes on dc9e90aeb, with nothing else changed between the two runs.
Projectcaesar0301/treelib
Fix saved2020-01-13
Sharing licenceApache-2.0 · LICENSE
Change size+8 −6
What the code was meant to do, written into the code itself as a save note
fix root removal in remove_subtree
The change
| 732 | 732 | parent = self[nid].predecessor(self._identifier) | |
| 733 | 733 | ||
| 734 | 734 | removed = list(self.expand_tree(nid)) | |
| 735 | - | for id in removed: | |
| 736 | - | st._nodes.update({id: self._nodes.pop(id)}) | |
| 737 | - | st[id].clone_pointers(self._identifier, st.identifier) | |
| 738 | - | st[id].reset_pointers(self._identifier) | |
| 739 | - | if id == nid: | |
| 740 | - | st[id].set_predecessor(None, st.identifier) | |
| 735 | + | for id_ in removed: | |
| 736 | + | if id_ == self.root: | |
| 737 | + | self.root = None | |
| 738 | + | st._nodes.update({id_: self._nodes.pop(id_)}) | |
| 739 | + | st[id_].clone_pointers(self._identifier, st.identifier) | |
| 740 | + | st[id_].reset_pointers(self._identifier) | |
| 741 | + | if id_ == nid: | |
| 742 | + | st[id_].set_predecessor(None, st.identifier) | |
| 741 | 743 | self.__update_fpointer(parent, nid, self.node_class.DELETE) | |
| 742 | 744 | return st | |
| 743 | 745 |
The check that tells the two apart
fail→pass·tests/test_tree.py::TreeCase::test_remove_subtree_whole_tree
Check file tests/test_tree.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itad9985e70adb2ae49db3838dcf080d0e16c91dd3
Broken version dated2019-12-18
Moduletreelib.tree
Units changedTree
Fingerprint96c1d7ff00bf71be
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.