Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r88156:33719a46d098
Date: 2016-11-06 18:37 +0100
http://bitbucket.org/pypy/pypy/changeset/33719a46d098/

Log:    Fixes: one file used to let RPython-level OSError escape; the other,
        DLOpenError.

diff --git a/pypy/module/_rawffi/alt/interp_funcptr.py 
b/pypy/module/_rawffi/alt/interp_funcptr.py
--- a/pypy/module/_rawffi/alt/interp_funcptr.py
+++ b/pypy/module/_rawffi/alt/interp_funcptr.py
@@ -325,6 +325,8 @@
             self.cdll = libffi.CDLL(name, mode)
         except DLOpenError as e:
             raise wrap_dlopenerror(space, e, self.name)
+        except OSError as e:
+            raise wrap_oserror(space, e)
 
     def getfunc(self, space, w_name, w_argtypes, w_restype):
         return _getfunc(space, self, w_name, w_argtypes, w_restype)
@@ -376,8 +378,4 @@
 # ========================================================================
 
 def get_libc(space):
-    try:
-        return space.wrap(W_CDLL(space, get_libc_name(), -1))
-    except OSError as e:
-        raise wrap_oserror(space, e)
-
+    return space.wrap(W_CDLL(space, get_libc_name(), -1))
diff --git a/pypy/module/_rawffi/interp_rawffi.py 
b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -224,14 +224,17 @@
             raise oefmt(space.w_ValueError, "Cannot find symbol %s", name)
         return space.wrap(address_as_uint)
 
+def open_cdll(space, name):
+    try:
+        return CDLL(name)
+    except DLOpenError as e:
+        raise wrap_dlopenerror(space, e, name or "<None>")
+    except OSError as e:
+        raise wrap_oserror(space, e)
+
 @unwrap_spec(name='str_or_None')
 def descr_new_cdll(space, w_type, name):
-    try:
-        cdll = CDLL(name)
-    except DLOpenError as e:
-        raise wrap_dlopenerror(space, e, name)
-    except OSError as e:
-        raise wrap_oserror(space, e)
+    cdll = open_cdll(space, name)
     return space.wrap(W_CDLL(space, name, cdll))
 
 W_CDLL.typedef = TypeDef(
@@ -620,10 +623,7 @@
 
 def get_libc(space):
     name = get_libc_name()
-    try:
-        cdll = CDLL(name)
-    except OSError as e:
-        raise wrap_oserror(space, e)
+    cdll = open_cdll(space, name)
     return space.wrap(W_CDLL(space, name, cdll))
 
 def get_errno(space):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to