diff options
Diffstat (limited to 'Python/dynload_shlib.c')
-rw-r--r-- | Python/dynload_shlib.c | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 7ea510e..46fed6e 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -18,10 +18,6 @@ #ifdef HAVE_DLFCN_H #include <dlfcn.h> -#else -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#include "dlfcn.h" -#endif #endif #if (defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__) @@ -36,31 +32,20 @@ live in the same directory. E.g. foomodule.cpython-32.so */ -const struct filedescr _PyImport_DynLoadFiletab[] = { +const char *_PyImport_DynLoadFiletab[] = { #ifdef __CYGWIN__ - {".dll", "rb", C_EXTENSION}, - {"module.dll", "rb", C_EXTENSION}, + ".dll", #else /* !__CYGWIN__ */ -#if defined(PYOS_OS2) && defined(PYCC_GCC) - {".pyd", "rb", C_EXTENSION}, - {".dll", "rb", C_EXTENSION}, -#else /* !(defined(PYOS_OS2) && defined(PYCC_GCC)) */ #ifdef __VMS - {".exe", "rb", C_EXTENSION}, - {".EXE", "rb", C_EXTENSION}, - {"module.exe", "rb", C_EXTENSION}, - {"MODULE.EXE", "rb", C_EXTENSION}, + ".exe", + ".EXE", #else /* !__VMS */ - {"." SOABI ".so", "rb", C_EXTENSION}, - {"module." SOABI ".so", "rb", C_EXTENSION}, - {".abi" PYTHON_ABI_STRING ".so", "rb", C_EXTENSION}, - {"module.abi" PYTHON_ABI_STRING ".so", "rb", C_EXTENSION}, - {".so", "rb", C_EXTENSION}, - {"module.so", "rb", C_EXTENSION}, + "." SOABI ".so", + ".abi" PYTHON_ABI_STRING ".so", + ".so", #endif /* __VMS */ -#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */ #endif /* __CYGWIN__ */ - {0, 0} + NULL, }; static struct { @@ -75,7 +60,7 @@ static struct { static int nhandles = 0; -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, +dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, const char *pathname, FILE *fp) { dl_funcptr p; @@ -117,13 +102,7 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, } } -#if !(defined(PYOS_OS2) && defined(PYCC_GCC)) dlopenflags = PyThreadState_GET()->interp->dlopenflags; -#endif - - if (Py_VerboseFlag) - PySys_WriteStderr("dlopen(\"%s\", %x);\n", pathname, - dlopenflags); #ifdef __VMS /* VMS currently don't allow a pathname, use a logical name instead */ @@ -139,10 +118,30 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, handle = dlopen(pathname, dlopenflags); if (handle == NULL) { + PyObject *mod_name; + PyObject *path; + PyObject *error_ob; const char *error = dlerror(); if (error == NULL) error = "unknown dlopen() error"; - PyErr_SetString(PyExc_ImportError, error); + error_ob = PyUnicode_FromString(error); + if (error_ob == NULL) + return NULL; + mod_name = PyUnicode_FromString(shortname); + if (mod_name == NULL) { + Py_DECREF(error_ob); + return NULL; + } + path = PyUnicode_FromString(pathname); + if (path == NULL) { + Py_DECREF(error_ob); + Py_DECREF(mod_name); + return NULL; + } + PyErr_SetImportError(error_ob, mod_name, path); + Py_DECREF(error_ob); + Py_DECREF(mod_name); + Py_DECREF(path); return NULL; } if (fp != NULL && nhandles < 128) |