[pypy-commit] pypy py3tests: Fix issues with appleveldefs in submodules

rlamy pypy.commits at gmail.com
Thu Apr 19 12:57:20 EDT 2018


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3tests
Changeset: r94383:81ecef10320d
Date: 2018-04-19 17:53 +0100
http://bitbucket.org/pypy/pypy/changeset/81ecef10320d/

Log:	Fix issues with appleveldefs in submodules

diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -30,17 +30,21 @@
 
     @not_rpython
     def install(self):
-        """install this module, and it's submodules into
+        """Install this module, and its submodules into
         space.builtin_modules"""
         Module.install(self)
         if hasattr(self, "submodules"):
             space = self.space
-            name = space.text_w(self.w_name)
+            pkgname = space.text_w(self.w_name)
             for sub_name, module_cls in self.submodules.iteritems():
                 if module_cls.submodule_name is None:
                     module_cls.submodule_name = sub_name
-                module_name = space.newtext("%s.%s" % (name, sub_name))
-                m = module_cls(space, module_name)
+                else:
+                    assert module_cls.submodule_name == sub_name
+                name = "%s.%s" % (pkgname, sub_name)
+                module_cls.applevel_name = name
+                w_name = space.newtext(name)
+                m = module_cls(space, w_name)
                 m.install()
                 self.submodules_w.append(m)
 
@@ -175,8 +179,6 @@
             cls.loaders = loaders = {}
             pkgroot = cls.__module__.rsplit('.', 1)[0]
             appname = cls.get_applevel_name()
-            if cls.submodule_name is not None:
-                appname += '.%s' % (cls.submodule_name,)
             for name, spec in cls.interpleveldefs.items():
                 loaders[name] = getinterpevalloader(pkgroot, spec)
             for name, spec in cls.appleveldefs.items():
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
@@ -34,7 +34,10 @@
     m.install()
 
     assert space.builtin_modules["test_module"] is m
-    assert isinstance(space.builtin_modules["test_module.sub"], SubModule)
+    submod = space.builtin_modules["test_module.sub"]
+    assert isinstance(submod, SubModule)
+    assert submod.get_applevel_name() == "test_module.sub"
+
 
 class AppTestMixedModule(object):
     pytestmark = pytest.mark.skipif("config.option.runappdirect")
diff --git a/pypy/module/__pypy__/app_signal.py b/pypy/module/__pypy__/app_signal.py
--- a/pypy/module/__pypy__/app_signal.py
+++ b/pypy/module/__pypy__/app_signal.py
@@ -1,4 +1,4 @@
-from . import thread
+from .thread import _signals_enter, _signals_exit
 # ^^ relative import of __pypy__.thread.  Note that some tests depend on
 # this (test_enable_signals in test_signal.py) to work properly,
 # otherwise they get caught in some deadlock waiting for the import
@@ -13,7 +13,7 @@
 that is within a "with signals_enabled:".  This other thread should be
 ready to handle unexpected exceptions that the signal handler might
 raise --- notably KeyboardInterrupt.'''
-    __enter__ = thread._signals_enter
-    __exit__  = thread._signals_exit
+    __enter__ = _signals_enter
+    __exit__  = _signals_exit
 
 signals_enabled = SignalsEnabled()


More information about the pypy-commit mailing list