Commits

Amaury Forgeot d'Arc committed 88b31a5

Implement PyImport_ReloadModule

Comments (0)

Files changed (2)

pypy/module/cpyext/import_.py

     space.warn('PyImport_ImportModuleNoBlock() is not non-blocking',
                space.w_RuntimeWarning)
     return PyImport_Import(space, space.wrap(rffi.charp2str(name)))
+
+@cpython_api([PyObject], PyObject)
+def PyImport_ReloadModule(space, w_mod):
+    from pypy.module.imp.importing import reload
+    return reload(space, w_mod)
+

pypy/module/cpyext/test/test_import.py

         assert pdb
         assert space.getattr(pdb, space.wrap("pm"))
 
+    def test_reload(self, space, api):
+        pdb = api.PyImport_Import(space.wrap("pdb"))
+        space.delattr(pdb, space.wrap("set_trace"))
+        pdb = api.PyImport_ReloadModule(pdb)
+        assert space.getattr(pdb, space.wrap("set_trace"))
+
 class AppTestImportLogic(AppTestCpythonExtensionBase):
     def test_import_logic(self):
         skip("leak?")