From 214cb56246df534220385a17974b37a47ecf8e77 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Sun, 10 Oct 2021 01:20:39 +1100 Subject: [PATCH] Restore warning about re-patching ast --- rope/refactor/patchedast.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rope/refactor/patchedast.py b/rope/refactor/patchedast.py index 5a8c59dd7..d8ed4e063 100644 --- a/rope/refactor/patchedast.py +++ b/rope/refactor/patchedast.py @@ -97,6 +97,15 @@ def __call__(self, node): node.sorted_children = ast.get_children(node) def _handle(self, node, base_children, eat_parens=False, eat_spaces=False): + if hasattr(node, "region"): + # ???: The same node was seen twice; what should we do? + warnings.warn( + "Node <%s> has been already patched; please report!" + % node.__class__.__name__, + RuntimeWarning, + ) + return + base_children = collections.deque(base_children) self.children_stack.append(base_children) children = collections.deque()