Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: multiphase
Changeset: r92113:c0c2ccfe883f
Date: 2017-08-09 03:40 +0200
http://bitbucket.org/pypy/pypy/changeset/c0c2ccfe883f/

Log:    Add test

diff --git a/pypy/module/cpyext/test/multiphase2.c 
b/pypy/module/cpyext/test/multiphase2.c
--- a/pypy/module/cpyext/test/multiphase2.c
+++ b/pypy/module/cpyext/test/multiphase2.c
@@ -417,7 +417,7 @@
     PyDoc_STR("Not a PyModuleObject object, but requests per-module state"),
     10,                                         /* m_size */
     NULL,                                       /* m_methods */
-    //slots_create_nonmodule,                     /* m_slots */
+    slots_create_nonmodule,                     /* m_slots */
     NULL,                                       /* m_traverse */
     NULL,                                       /* m_clear */
     NULL,                                       /* m_free */
@@ -436,7 +436,7 @@
     PyDoc_STR("PyModuleDef with negative m_size"),
     -1,                                         /* m_size */
     NULL,                                       /* m_methods */
-    NULL, //slots_create_nonmodule,                     /* m_slots */
+    slots_create_nonmodule,                     /* m_slots */
     NULL,                                       /* m_traverse */
     NULL,                                       /* m_clear */
     NULL,                                       /* m_free */
diff --git a/pypy/module/cpyext/test/test_module.py 
b/pypy/module/cpyext/test/test_module.py
--- a/pypy/module/cpyext/test/test_module.py
+++ b/pypy/module/cpyext/test/test_module.py
@@ -175,3 +175,38 @@
         ex_class = module.Example
         importlib.reload(module)
         assert ex_class is module.Example
+
+    def w_load_from_spec(self, loader, spec):
+        from importlib import util
+        module = util.module_from_spec(spec)
+        loader.exec_module(module)
+        return module
+
+    def test_bad_modules(self):
+        # XXX: not a very good test, since most internal issues in cpyext
+        # cause SystemErrors.
+        from importlib import machinery, util
+        NAME = 'multiphase2'
+        module = self.import_module(name=NAME)
+        origin = module.__loader__.path
+        for name_base in [
+                'bad_slot_large',
+                'bad_slot_negative',
+                'create_int_with_state',
+                'negative_size',
+                'export_null',
+                'export_uninitialized',
+                'export_raise',
+                'export_unreported_exception',
+                'create_null',
+                'create_raise',
+                'create_unreported_exception',
+                'nonmodule_with_exec_slots',
+                'exec_err',
+                'exec_raise',
+                'exec_unreported_exception',
+                ]:
+            name = '_testmultiphase_' + name_base
+            loader = machinery.ExtensionFileLoader(name, origin)
+            spec = util.spec_from_loader(name, loader)
+            raises(SystemError, self.load_from_spec, loader, spec)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to