[pypy-svn] r75062 - in pypy/branch/fast-ctypes/pypy/rlib: . test

getxsick at codespeak.net getxsick at codespeak.net
Thu Jun 3 19:36:27 CEST 2010


Author: getxsick
Date: Thu Jun  3 19:36:26 2010
New Revision: 75062

Modified:
   pypy/branch/fast-ctypes/pypy/rlib/jitffi.py
   pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py
Log:
kill space


Modified: pypy/branch/fast-ctypes/pypy/rlib/jitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/jitffi.py	(original)
+++ pypy/branch/fast-ctypes/pypy/rlib/jitffi.py	Thu Jun  3 19:36:26 2010
@@ -1,4 +1,3 @@
-from pypy.interpreter.error import operationerrfmt
 from pypy.rlib import rdynload
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.jit.backend.x86.runner import CPU
@@ -11,9 +10,9 @@
     def __init__(self, name):
         try:
             self.lib = rdynload.dlopen(name)
-        except libffi.DLOpenError, e:
-            raise operationerrfmt(space.w_OSError, '%s: %s', name,
-                                  e.msg or 'unspecified error')
+        except rdynload.DLOpenError, e:
+            raise OSError('%s: %s', name, e.msg or 'unspecified error')
+
         self.name = name
         self.cpu = CPU(None, None)
 
@@ -35,8 +34,7 @@
         try:
             addr = rffi.cast(lltype.Signed, rdynload.dlsym(self.lib, func))
         except KeyError:
-            raise operationerrfmt(space.w_ValueError,
-                                  "Cannot find symbol %s", func)
+            raise ValueError("Cannot find symbol %s", func)
         bfuncaddr = BoxInt(addr)
 
         args_type = [ lltype.Signed for i in func_args ]
@@ -107,8 +105,7 @@
         try:
             addr = rffi.cast(lltype.Signed, rdynload.dlsym(self.lib, func))
         except KeyError:
-            raise operationerrfmt(space.w_ValueError,
-                                  "Cannot find symbol %s", func)
+            raise ValueError("Cannot find symbol %s", func)
         self.bfuncaddr = BoxInt(addr)
 
         args = []

Modified: pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py	(original)
+++ pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py	Thu Jun  3 19:36:26 2010
@@ -43,6 +43,9 @@
     def setup_class(cls):
         cls.lib_name = cls.preprare_c_example()
 
+    def test_missing_lib(self):
+        py.test.raises(OSError, jitffi.CDLL, 'xxxfoo888baryyy')
+
     def test_call(self):
         lib = jitffi.CDLL(self.lib_name)
 
@@ -83,3 +86,9 @@
         lib = jitffi.CDLL(self.lib_name)
         py.test.raises(ValueError, lib.get,
                        'add_integers', ['void', 'int'], 'int')
+
+    def test_undefined_func(self):
+        lib = jitffi.CDLL(self.lib_name)
+        # xxxfoo888baryyy - not existed function
+        py.test.raises(ValueError, lib.get, 'xxxfoo888baryyy', [])
+        py.test.raises(ValueError, lib.get, 'xxxfoo888baryyy', ['int'], 'int')



More information about the Pypy-commit mailing list