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.

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

673673 """Remove a node indicated by 'identifier' with all its successors.
674674 Return the number of removed nodes.
675675 """
676- if identifier is None:
677- return 0
678-
679676 if not self.contains(identifier):
680677 raise NodeIDAbsentError("Node '%s' "
681678 "is not in the tree" % identifier)
686683 removed = list(self.expand_tree(identifier))
687684
688685 for id_ in removed:
686+ if id_ == self.root:
687+ self.root = None
689688 self.__update_bpointer(id_, None)
690689 for cid in self[id_].successors(self._identifier) or []:
691690 self.__update_fpointer(id_, cid, self.node_class.DELETE)

The check that tells the two apart

failpass·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.

Other bugs found in caesar0301/treelib