Commit f0674993 authored by Stefan Behnel's avatar Stefan Behnel

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

--HG--
extra : transplant_source : K%11N4%9E%E83%3A%3F%84%DFr%7Ca%DEP%22%5D%1B%9E
parent b786d429
...@@ -9448,12 +9448,31 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) { ...@@ -9448,12 +9448,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