From: Jack Jansen Date: Tue, 25 Feb 2003 14:20:44 +0000 (+0000) Subject: Partial backport of 2.11: better error messages on import failures. X-Git-Tag: v2.2.3c1~121 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=427ee3bbddbc8bd8b22868c24c96123728f15889;p=thirdparty%2FPython%2Fcpython.git Partial backport of 2.11: better error messages on import failures. Fixes #652590. --- diff --git a/Python/dynload_next.c b/Python/dynload_next.c index 892bb478424b..6789bfeeddcb 100644 --- a/Python/dynload_next.c +++ b/Python/dynload_next.c @@ -120,6 +120,7 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, NSModule newModule; NSSymbol theSym; const char *errString; + char errBuf[512]; if (NSIsSymbolNameDefined(funcname)) { theSym = NSLookupAndBindSymbol(funcname); @@ -150,8 +151,15 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, if (errString == NULL) { newModule = NSLinkModule(image, pathname, NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR); - if (!newModule) - errString = "Failure linking new module"; + if (newModule == NULL) { + int errNo; + char *fileName, *moreErrorStr; + NSLinkEditErrors c; + NSLinkEditError( &c, &errNo, &fileName, &moreErrorStr ); + PyOS_snprintf(errBuf, 512, "Failure linking new module: %s: %s", + fileName, moreErrorStr); + errString = errBuf; + } } if (errString != NULL) { PyErr_SetString(PyExc_ImportError, errString);