Commit cb40a3e6 authored by Stefan Behnel's avatar Stefan Behnel

work around Py3k importlib changes: old-style rel+abs imports are no longer supported

parent d6c9c5f7
...@@ -9572,12 +9572,31 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) { ...@@ -9572,12 +9572,31 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
goto bad; goto bad;
#if PY_VERSION_HEX >= 0x02050000 #if PY_VERSION_HEX >= 0x02050000
{ {
PyObject *py_level = PyInt_FromLong(level); #if PY_VERSION_HEX >= 0x03030000
if (!py_level) if (level == -1) {
goto bad; /* try relative import first */
module = PyObject_CallFunctionObjArgs(py_import, PyObject *py_level = PyInt_FromLong(1);
name, global_dict, empty_dict, list, py_level, NULL); if (!py_level)
Py_DECREF(py_level); goto bad;
module = PyObject_CallFunctionObjArgs(py_import,
name, global_dict, empty_dict, list, py_level, NULL);
Py_DECREF(py_level);
if (!module) {
if (!PyErr_ExceptionMatches(PyExc_ImportError))
goto bad;
PyErr_Clear();
level = 0; /* try absolute import on failure */
}
}
#endif
if (!module) {
PyObject *py_level = PyInt_FromLong(level);
if (!py_level)
goto bad;
module = PyObject_CallFunctionObjArgs(py_import,
name, global_dict, empty_dict, list, py_level, NULL);
Py_DECREF(py_level);
}
} }
#else #else
if (level>0) { if (level>0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment