Victor Stinner avatar Victor Stinner committed c91ab87

Remove Config._remove_module_dead_code option

Comments (0)

Files changed (3)


         #         pass
         self.remove_almost_dead_code = False
-        # Remove dead code in a module body?
-        # Option used by astoptimizer unit tests
-        # Example: "print('hello'); 1" => "print('hello')"
-        self._remove_module_dead_code = True
         # Remove documentation strings?
         # False by default, True if the option -O is specified
         # in the command line


         return new_constant(node, constant)
     def fullvisit_Module(self, node):
-        if self.config._remove_module_dead_code:
-            node.body = self.visit_expr_list(node.body)
-        else:
-            node.body = self.visit_list(node.body)
+        node.body = self.visit_expr_list(node.body)
     def get_attribute_name(self, node):
         if isinstance(node.value, ast.Name):


         config = _Config(*features)
         config.info_func = self.log_info
         config.warning_func = self.log_warning
-        config._remove_module_dead_code = False
         return config
     def create_default_config(self):
     def test_Pass(self):
         self.check_pass('pass; pass')
-        self.check('pass; 1; pass', self.text_num(1))
+        self.check('pass; func(); pass', self.text_ast('func()'))
         self.check('if True:\n pass\n pass\nif False: pass', self.TEXT_PASS)
         self.check_pass('class Klass:\n pass\n pass')
     def test_remove_almost_dead_code(self):
         config = self.create_config()
         config.remove_almost_dead_code = True
-        config._remove_module_dead_code = True
         # disable removal of dead code
         config = self.create_config()
         config.remove_dead_code = False
-        config._remove_module_dead_code = True
         config.unroll_limit = 0
         self.check_not_optimized('def f():\n return 1\n return 2', config)
         self.check('if False: print("log")',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.