[pypy-commit] pypy stmgc-c7: merge heads

arigo noreply at buildbot.pypy.org
Thu Apr 10 12:36:59 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r70536:576da3e3bdab
Date: 2014-04-10 12:36 +0200
http://bitbucket.org/pypy/pypy/changeset/576da3e3bdab/

Log:	merge heads

diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -24,7 +24,7 @@
         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"):
@@ -33,6 +33,8 @@
             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)
 
diff --git a/pypy/interpreter/test/test_mixedmodule.py b/pypy/interpreter/test/test_mixedmodule.py
--- a/pypy/interpreter/test/test_mixedmodule.py
+++ b/pypy/interpreter/test/test_mixedmodule.py
@@ -18,11 +18,25 @@
             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"))
@@ -30,6 +44,8 @@
 
         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")
diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -43,6 +43,8 @@
         '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):


More information about the pypy-commit mailing list