diff Python/importdl.c @ 76434:573010778eed

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.
author Brett Cannon <brett@python.org>
date Fri, 20 Apr 2012 15:22:50 -0400
parents 2dd046be2c88
children 4343dfaca8e2
line wrap: on
line diff
--- a/Python/importdl.c	Fri Apr 20 19:59:20 2012 +0200
+++ b/Python/importdl.c	Fri Apr 20 15:22:50 2012 -0400
@@ -74,10 +74,11 @@
     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;