Commits

Armin Rigo committed 64954c8

Deactivate the submodule '__pypy__.thread' if we're translating without
threads.

Comments (0)

Files changed (3)

pypy/interpreter/mixedmodule.py

         self.submodules_w = []
 
     def install(self):
-        """NOT_RPYTHON: install this module, and it's submodules into
+        """NOT_RPYTHON: install this module, and its submodules into
         space.builtin_modules"""
         Module.install(self)
         if hasattr(self, "submodules"):
             for sub_name, module_cls in self.submodules.iteritems():
                 module_name = space.wrap("%s.%s" % (name, sub_name))
                 m = module_cls(space, module_name)
+                if hasattr(m, 'activate') and not m.activate(space):
+                    continue
                 m.install()
                 self.submodules_w.append(m)
 

pypy/interpreter/test/test_mixedmodule.py

             interpleveldefs = {}
             appleveldefs = {}
 
+        class SubModule1(MixedModule):
+            interpleveldefs = {}
+            appleveldefs = {}
+            def activate(self, space):
+                return True
+
+        class SubModule2(MixedModule):
+            interpleveldefs = {}
+            appleveldefs = {}
+            def activate(self, space):
+                return False
+
         class Module(MixedModule):
             interpleveldefs = {}
             appleveldefs = {}
             submodules = {
-                "sub": SubModule
+                "sub": SubModule,
+                "sub1": SubModule1,
+                "sub2": SubModule2,
             }
 
         m = Module(self.space, self.space.wrap("test_module"))
 
         assert self.space.builtin_modules["test_module"] is m
         assert isinstance(self.space.builtin_modules["test_module.sub"], SubModule)
+        assert "test_module.sub1" in self.space.builtin_modules
+        assert "test_module.sub2" not in self.space.builtin_modules
 
 class AppTestMixedModule(object):
     pytestmark = py.test.mark.skipif("config.option.runappdirect")

pypy/module/__pypy__/__init__.py

         'discard_last_abort_info': 'interp_atomic.discard_last_abort_info',
         'getsegmentlimit':         'interp_atomic.getsegmentlimit',
     }
+    def activate(self, space):
+        return self.space.config.objspace.usemodules.thread
 
 
 class IntOpModule(MixedModule):