Author: Wim Lavrijsen <[email protected]>
Branch: cppyy-packaging
Changeset: r92079:65f1498d698a
Date: 2017-08-04 15:19 -0700
http://bitbucket.org/pypy/pypy/changeset/65f1498d698a/

Log:    add 'cppyy.gbl.namespace' to sys.modules, instead of
        '_cppyy.gbl.namespace' (to move to frontend, later)

diff --git a/pypy/module/_cppyy/pythonify.py b/pypy/module/_cppyy/pythonify.py
--- a/pypy/module/_cppyy/pythonify.py
+++ b/pypy/module/_cppyy/pythonify.py
@@ -126,7 +126,7 @@
             setattr(metans, dm_name, cppdm)
 
         modname = pycppns.__name__.replace('::', '.')
-        sys.modules['_cppyy.gbl.'+modname] = pycppns
+        sys.modules['cppyy.gbl.'+modname] = pycppns   # note naming (cppyy)
     return pycppns
 
 def _drop_cycles(bases):
@@ -444,9 +444,9 @@
     # install for user access
     _cppyy.gbl = gbl
 
-    # install as modules to allow importing from
-    sys.modules['_cppyy.gbl'] = gbl
-    sys.modules['_cppyy.gbl.std'] = gbl.std
+    # install as modules to allow importing from (note naming: cppyy)
+    sys.modules['cppyy.gbl'] = gbl
+    sys.modules['cppyy.gbl.std'] = gbl.std
 
 # user-defined pythonizations interface
 _pythonizations = {}
diff --git a/pypy/module/_cppyy/test/test_fragile.py 
b/pypy/module/_cppyy/test/test_fragile.py
--- a/pypy/module/_cppyy/test/test_fragile.py
+++ b/pypy/module/_cppyy/test/test_fragile.py
@@ -216,13 +216,18 @@
 
         # TODO: namespaces aren't loaded (and thus not added to sys.modules)
         # with just the from ... import statement; actual use is needed
-        from _cppyy.gbl import fragile
+
+        # TODO: this is really front-end testing, but the code is still in
+        # _cppyy, so we test it here until pythonify.py can be moved
+        import sys
+        sys.modules['cppyy'] = sys.modules['_cppyy']
+        from cppyy.gbl import fragile
 
         def fail_import():
-            from _cppyy.gbl import does_not_exist
+            from cppyy.gbl import does_not_exist
         raises(ImportError, fail_import)
 
-        from _cppyy.gbl.fragile import A, B, C, D
+        from cppyy.gbl.fragile import A, B, C, D
         assert _cppyy.gbl.fragile.A is A
         assert _cppyy.gbl.fragile.B is B
         assert _cppyy.gbl.fragile.C is C
@@ -230,18 +235,18 @@
 
         # according to warnings, can't test "import *" ...
 
-        from _cppyy.gbl.fragile import nested1
+        from cppyy.gbl.fragile import nested1
         assert _cppyy.gbl.fragile.nested1 is nested1
 
-        from _cppyy.gbl.fragile.nested1 import A, nested2
+        from cppyy.gbl.fragile.nested1 import A, nested2
         assert _cppyy.gbl.fragile.nested1.A is A
         assert _cppyy.gbl.fragile.nested1.nested2 is nested2
 
-        from _cppyy.gbl.fragile.nested1.nested2 import A, nested3
+        from cppyy.gbl.fragile.nested1.nested2 import A, nested3
         assert _cppyy.gbl.fragile.nested1.nested2.A is A
         assert _cppyy.gbl.fragile.nested1.nested2.nested3 is nested3
 
-        from _cppyy.gbl.fragile.nested1.nested2.nested3 import A
+        from cppyy.gbl.fragile.nested1.nested2.nested3 import A
         assert _cppyy.gbl.fragile.nested1.nested2.nested3.A is nested3.A
 
     def test12_missing_casts(self):
diff --git a/pypy/module/_cppyy/test/test_stltypes.py 
b/pypy/module/_cppyy/test/test_stltypes.py
--- a/pypy/module/_cppyy/test/test_stltypes.py
+++ b/pypy/module/_cppyy/test/test_stltypes.py
@@ -288,7 +288,7 @@
         """Test access to a list<int>"""
 
         import _cppyy
-        from _cppyy.gbl import std
+        std = _cppyy.gbl.std
 
         type_info = (
             ("int",     int),
@@ -323,7 +323,7 @@
         """Test behavior of empty list<int>"""
 
         import _cppyy
-        from _cppyy.gbl import std
+        std = _cppyy.gbl.std
 
         a = std.list(int)()
         for arg in a:
@@ -452,7 +452,7 @@
         """Test iterator comparison with operator== reflected"""
 
         import _cppyy
-        from _cppyy.gbl import std
+        std = _cppyy.gbl.std
 
         v = std.vector(int)()
         v.resize(1)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to