mirror of
https://github.com/python/cpython.git
synced 2025-07-16 15:55:18 +00:00
Issue #14599: Generalize a test for ImportError.path and add support
in Python/dynload_shlibs.c. This should fix the remaining importlib test failure on Windows. Support in AIX and HP-UX will be in a separate checkin.
This commit is contained in:
parent
3c23a87e58
commit
f0434e647a
4 changed files with 26 additions and 27 deletions
|
@ -129,10 +129,19 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname,
|
|||
handle = dlopen(pathname, dlopenflags);
|
||||
|
||||
if (handle == NULL) {
|
||||
PyObject *mod_name = NULL;
|
||||
PyObject *path = NULL;
|
||||
PyObject *error_ob = NULL;
|
||||
const char *error = dlerror();
|
||||
if (error == NULL)
|
||||
error = "unknown dlopen() error";
|
||||
PyErr_SetString(PyExc_ImportError, error);
|
||||
error_ob = PyUnicode_FromString(error);
|
||||
path = PyUnicode_FromString(pathname);
|
||||
mod_name = PyUnicode_FromString(shortname);
|
||||
PyErr_SetImportError(error_ob, mod_name, path);
|
||||
Py_DECREF(error_ob);
|
||||
Py_DECREF(path);
|
||||
Py_DECREF(mod_name);
|
||||
return NULL;
|
||||
}
|
||||
if (fp != NULL && nhandles < 128)
|
||||
|
|
|
@ -74,10 +74,11 @@ _PyImport_LoadDynamicModule(PyObject *name, PyObject *path, FILE *fp)
|
|||
if (PyErr_Occurred())
|
||||
goto error;
|
||||
if (p == NULL) {
|
||||
PyErr_Format(PyExc_ImportError,
|
||||
"dynamic module does not define init function"
|
||||
" (PyInit_%s)",
|
||||
shortname);
|
||||
PyObject *msg = PyUnicode_FromFormat("dynamic module does not define "
|
||||
"init function (PyInit_%s)",
|
||||
shortname);
|
||||
PyErr_SetImportError(msg, name, path);
|
||||
Py_DECREF(msg);
|
||||
goto error;
|
||||
}
|
||||
oldcontext = _Py_PackageContext;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue