[pypy-svn] r72615 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test

afa at codespeak.net afa at codespeak.net
Tue Mar 23 13:17:23 CET 2010


Author: afa
Date: Tue Mar 23 13:17:21 2010
New Revision: 72615

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/api.py
   pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
Log:
Fix exception message and add a test
--Cette ligne, et les suivantes ci-dessous, seront ignorées--

M    api.py
M    test/test_cpyext.py


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/api.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/api.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/api.py	Tue Mar 23 13:17:21 2010
@@ -343,11 +343,11 @@
     from pypy.rlib import libffi
     try:
         dll = libffi.CDLL(path)
-    except libffi.DLOpenError:
+    except libffi.DLOpenError, e:
         raise operationerrfmt(
             space.w_ImportError,
-            "unable to load extension module %s",
-            path)
+            "unable to load extension module '%s': %s",
+            path, e.msg)
     try:
         initfunc = dll.getpointer(
             'init%s' % (name,), [], libffi.ffi_type_void)

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py	Tue Mar 23 13:17:21 2010
@@ -32,6 +32,17 @@
         assert rffi.sizeof(T) == 42
         print T
 
+class AppTestApi:
+    def setup_class(cls):
+        cls.space = gettestobjspace(usemodules=['cpyext'])
+        from pypy.rlib.libffi import get_libc_name
+        cls.w_libc = cls.space.wrap(get_libc_name())
+
+    def test_load_error(self):
+        import cpyext
+        raises(ImportError, cpyext.load_module, "missing.file", "foo")
+        raises(ImportError, cpyext.load_module, self.libc, "invalid.function")
+
 def compile_module(modname, **kwds):
     eci = ExternalCompilationInfo(
         export_symbols=['init%s' % (modname,)],



More information about the Pypy-commit mailing list