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,6 +9572,24 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
goto bad;
#if PY_VERSION_HEX >= 0x02050000
{
#if PY_VERSION_HEX >= 0x03030000
if (level == -1) {
/* try relative import first */
PyObject *py_level = PyInt_FromLong(1);
if (!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;
......@@ -9579,6 +9597,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
name, global_dict, empty_dict, list, py_level, NULL);
Py_DECREF(py_level);
}
}
#else
if (level>0) {
PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
......
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