Author: Wim Lavrijsen <wlavrij...@lbl.gov> Branch: cling-support Changeset: r85701:6d4c1909c9ad Date: 2016-07-14 09:30 -0700 http://bitbucket.org/pypy/pypy/changeset/6d4c1909c9ad/
Log: from Aditi: proper message on failure to load dictionary file diff --git a/pypy/module/cppyy/interp_cppyy.py b/pypy/module/cppyy/interp_cppyy.py --- a/pypy/module/cppyy/interp_cppyy.py +++ b/pypy/module/cppyy/interp_cppyy.py @@ -32,6 +32,9 @@ def load_dictionary(space, name): try: cdll = capi.c_load_dictionary(name) + if not cdll: + raise OperationError(space.w_RuntimeError, space.wrap(str("could not load dictionary " + name))) + except rdynload.DLOpenError as e: raise OperationError(space.w_RuntimeError, space.wrap(str(e.msg))) return W_CPPLibrary(space, cdll) diff --git a/pypy/module/cppyy/src/clingcwrapper.cxx b/pypy/module/cppyy/src/clingcwrapper.cxx --- a/pypy/module/cppyy/src/clingcwrapper.cxx +++ b/pypy/module/cppyy/src/clingcwrapper.cxx @@ -20,6 +20,7 @@ #include "TMethod.h" #include "TMethodArg.h" #include "TROOT.h" +#include "TSystem.h" // Standard #include <assert.h> @@ -165,9 +166,10 @@ if ( icr != g_name2classrefidx.end() ) return (TCppType_t)icr->second; - // use TClass directly, to enable auto-loading +// use TClass directly, to enable auto-loading; class may be stubbed (eg. for +// function returns) leading to a non-null TClass that is otherwise invalid TClassRef cr( TClass::GetClass( scope_name.c_str(), kTRUE, kTRUE ) ); - if ( !cr.GetClass() ) + if ( !cr.GetClass() || !cr->Property() ) return (TCppScope_t)NULL; // no check for ClassInfo as forward declared classes are okay (fragile) @@ -1390,7 +1392,8 @@ /* misc helpers ----------------------------------------------------------- */ RPY_EXTERN void* cppyy_load_dictionary(const char* lib_name) { - return (void*)(gInterpreter->Load(lib_name) == 0); + int result = gSystem->Load(lib_name); + return (void*)(result == 0 /* success */ || result == 1 /* already loaded */); } long long cppyy_strtoll(const char* str) { diff --git a/pypy/module/cppyy/test/test_cppyy.py b/pypy/module/cppyy/test/test_cppyy.py --- a/pypy/module/cppyy/test/test_cppyy.py +++ b/pypy/module/cppyy/test/test_cppyy.py @@ -4,7 +4,7 @@ currpath = py.path.local(__file__).dirpath() -test_dct = str(currpath.join("example01_rflx_rdict.pcm"))#example01Dict.so")) +test_dct = str(currpath.join("example01Dict.so")) def setup_module(mod): if sys.platform == 'win32': _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit