Commits

Nick Coghlan committed 4f15246

Actually initialise the module

Comments (0)

Files changed (2)

Lib/test/test_importlib/extension/test_loader.py

                                 ('__file__', modpath),
                                 ('__package__', '')]:
                 self.assertEqual(getattr(module, attr), value)
+            for attr in ("Example", "error", "Str", "Null"):
+                self.assertIsInstance(getattr(module, attr), type)
+            for attr in ("foo", "roj", "new"):
+                self.assertTrue(callable(getattr(module, attr)))
+            example = module.Example()
+            self.assertEqual(example.demo("text"), "text")
+            self.assertIsNone(example.demo(1))
             self.assertIn(modname, sys.modules)
             self.assertIsInstance(module.__loader__,
                                   machinery.ExtensionFileLoader)
 
+    def test_fresh_modules(self):
+        modname = self.mod_info.name
+        with util.uncache(modname):
+            module1 = self.load_module(modname)
+            module2 = self.load_module(modname)
+            self.assertIsNot(module1, module2)
+
 
 def test_main():
     from test.support import run_unittest

Python/importdl.c

      * Initial prototype is implemented in dynload_shlib only
      */
     dl_funcptr raw_exec_module, raw_create_module;
+    int (*exec_module)(PyObject *);
     PyObject* m = NULL, *modules = NULL;
     PyObject *nameascii = NULL;
     char *shortname, *packagecontext;
     }
 
     /* Initialize the module */
-    /* TODO! */
+    exec_module = (int(*)(PyObject *))raw_exec_module;
+    if ((*exec_module)(m) != 0) {
+        goto error;
+    }
+
 
     Py_DECREF(nameascii);
     return m;