Whole file
caesar0301/treelib
The author described this change as “fix removal of root node”. It counts as a record because the check below fails on the code as it stood at 7cb27820c and passes on a4dedfd4d, with nothing else changed between the two runs.
Projectcaesar0301/treelib
Fix saved2019-12-18
Sharing licenceApache-2.0 · LICENSE
Change size+2 −3
What the code was meant to do, written into the code itself as a save note
fix removal of root node
The change
| 673 | 673 | """Remove a node indicated by 'identifier' with all its successors. | |
| 674 | 674 | Return the number of removed nodes. | |
| 675 | 675 | """ | |
| 676 | - | if identifier is None: | |
| 677 | - | return 0 | |
| 678 | - | ||
| 679 | 676 | if not self.contains(identifier): | |
| 680 | 677 | raise NodeIDAbsentError("Node '%s' " | |
| 681 | 678 | "is not in the tree" % identifier) | |
| ⋯ | |||
| 686 | 683 | removed = list(self.expand_tree(identifier)) | |
| 687 | 684 | ||
| 688 | 685 | for id_ in removed: | |
| 686 | + | if id_ == self.root: | |
| 687 | + | self.root = None | |
| 689 | 688 | self.__update_bpointer(id_, None) | |
| 690 | 689 | for cid in self[id_].successors(self._identifier) or []: | |
| 691 | 690 | self.__update_fpointer(id_, cid, self.node_class.DELETE) | |
The check that tells the two apart
fail→pass·tests/test_tree.py::TreeCase::test_root_removal
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 it7cb27820c2db43628ee80f7851b43ffeb15f92ef
Broken version dated2019-12-15
Moduletreelib.tree
Units changedTree
Fingerprintd8f6d0f656d3abbf
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.