Anders Hammarquist avatar Anders Hammarquist committed 2b6e6f1

CPytthon imp.find_modules returns open fd even for extension modules.
Do same, so xapian will load.
WIP - the test segfaults when run with pypy-c

Comments (0)

Files changed (2)

pypy/module/imp/importing.py

                     space.warn(msg, space.w_ImportWarning)
             modtype, suffix, filemode = find_modtype(space, filepart)
             try:
-                if modtype in (PY_SOURCE, PY_COMPILED):
+                if modtype in (PY_SOURCE, PY_COMPILED, C_EXTENSION):
                     assert suffix is not None
                     filename = filepart + suffix
                     stream = streamio.open_file_as_stream(filename, filemode)
                     except:
                         stream.close()
                         raise
-                if modtype == C_EXTENSION:
-                    filename = filepart + suffix
-                    return FindInfo(modtype, filename, None, suffix, filemode)
+                # if modtype == C_EXTENSION:
+                #     filename = filepart + suffix
+                #     return FindInfo(modtype, filename, None, suffix, filemode)
             except StreamErrors:
                 pass
 

pypy/module/imp/test/test_app.py

 from __future__ import with_statement
 MARKER = 42
 
+try:
+    from pypy.conftest import gettestobjspace    
+    from pypy.module.cpyext.state import State
+    from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
+
+    class AppTestImpCModule(AppTestCpythonExtensionBase):
+        def setup_class(cls):
+            cls.space = gettestobjspace(usemodules=['cpyext', '_rawffi'])
+            cls.w_imp = cls.space.getbuiltinmodule('imp')
+            cls.w_file_module = cls.space.wrap(__file__)
+            state = cls.space.fromcache(State)
+            state.build_api(cls.space)
+
+        def test_find_module_cpyext(self):
+            import os
+            mod = self.compile_module('test_import_module',
+                                      separate_module_files=[self.here + 'test_import_module.c'])
+
+            fp, pathname, description = self.imp.find_module('test_import_module',
+                                                             [os.path.dirname(mod)])
+            assert fp is not None
+            assert pathname == mod
+except ImportError:
+    pass
+
 class AppTestImpModule:
     def setup_class(cls):
         cls.w_imp = cls.space.getbuiltinmodule('imp')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.