Commits

Victor Stinner committed ffd993b

log removal of empty try/except

  • Participants
  • Parent commits 32b0134

Comments (0)

Files changed (1)

File astoptimizer/optimizer.py

                 if is_empty_body(node.orelse):
                     # try: pass finally: code
                     # => code
+                    self.log_node_removal(node)
                     return self.if_block(node, node.finalbody)
                 elif is_empty_body(node.finalbody):
                     # try: pass except: ... else: code
                     # => code
+                    self.log_node_removal(node)
                     return self.if_block(node, node.orelse)
                 else:
                     # try: pass except: ... else: code1 finally: code2
                     # => try: code1 finally: code2
+                    self.log_node_removal(node)
                     node.body = node.orelse
                     del node.handlers[:]
                     node.orelse = []
             and is_empty_body(node.body)):
                 # try: pass finally: code
                 # => code
+                self.log_node_removal(node)
                 return self.if_block(node, node.finalbody)
 
         def fullvisit_TryExcept(self, node):
             and is_empty_body(node.body)):
                 # try: pass except: ... else: code
                 # => code
+                self.log_node_removal(node)
                 return self.if_block(node, node.orelse)
             node.handlers = self.visit_list(node.handlers, True)