[pypy-commit] pypy cffi-1.0: Improve the error message when dependent modules cannot be loaded
arigo
noreply at buildbot.pypy.org
Sat May 9 22:05:16 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r77262:ca7234416c2b
Date: 2015-05-09 22:05 +0200
http://bitbucket.org/pypy/pypy/changeset/ca7234416c2b/
Log: Improve the error message when dependent modules cannot be loaded
diff --git a/pypy/module/_cffi_backend/lib_obj.py b/pypy/module/_cffi_backend/lib_obj.py
--- a/pypy/module/_cffi_backend/lib_obj.py
+++ b/pypy/module/_cffi_backend/lib_obj.py
@@ -1,7 +1,7 @@
from rpython.rlib import jit
from rpython.rtyper.lltypesystem import lltype, rffi
-from pypy.interpreter.error import oefmt
+from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.gateway import interp2app
@@ -31,10 +31,17 @@
includes = []
while c_includes[num]:
include_name = rffi.charp2str(c_includes[num])
- w_lib1 = space.appexec([space.wrap(include_name)], """(modname):
- mod = __import__(modname, None, None, ['ffi', 'lib'])
- return mod.lib""")
- lib1 = space.interp_w(W_LibObject, w_lib1)
+ try:
+ w_lib1 = space.appexec([space.wrap(include_name)], """(modname):
+ mod = __import__(modname, None, None, ['ffi', 'lib'])
+ return mod.lib""")
+ lib1 = space.interp_w(W_LibObject, w_lib1)
+ except OperationError, e:
+ if e.async(space):
+ raise
+ raise oefmt(space.w_ImportError,
+ "while loading %s: failed to import ffi, lib from %s",
+ self.libname, include_name)
includes.append(lib1)
num += 1
self.ffi.included_libs = includes[:]
More information about the pypy-commit
mailing list