Attach a finalizer to the given node. The node must be currently active in the stack.
(self, finalizer: Callable[[], object], node: Node)
| 501 | raise exc |
| 502 | |
| 503 | def addfinalizer(self, finalizer: Callable[[], object], node: Node) -> None: |
| 504 | """Attach a finalizer to the given node. |
| 505 | |
| 506 | The node must be currently active in the stack. |
| 507 | """ |
| 508 | assert node and not isinstance(node, tuple) |
| 509 | assert callable(finalizer) |
| 510 | assert node in self.stack, (node, self.stack) |
| 511 | self.stack[node][0].append(finalizer) |
| 512 | |
| 513 | def teardown_exact(self, nextitem: Optional[Item]) -> None: |
| 514 | """Teardown the current stack up until reaching nodes that nextitem |