Commits

Victor Stinner  committed 58fd6cb

Fix Nonlocal for Python 3

  • Participants
  • Parent commits 010d52c

Comments (0)

Files changed (1)

File astoptimizer/optimizer.py

             filename = "<string>"
         where = "%s:%s" % (filename, node.lineno)
         text = ast.dump(node)
+        if len(text) > 100:
+            text = text[:100] + "..."
         self.info("Remove dead code at %s: %s" % (where, text))
 
     def warning(self, message):
             return not ast_contains(node_list, ast.Global)
 
     if PYTHON3:
-        def visit_Nonlocal(self, node):
+        def fullvisit_Nonlocal(self, node):
             for name in node.names:
                 self.namespace.unassign(name)
 
         return True
 
     def visit_expr_list(self, node_list, conditional=False):
-        if self.config.remove_dead_code:
+        if self.config.remove_dead_code and len(node_list):
             new_node_list = []
             for index, node in enumerate(node_list):
                 if self._remove_node(index, node):