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,6 +9448,24 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) { ...@@ -9448,6 +9448,24 @@ 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
{ {
#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); PyObject *py_level = PyInt_FromLong(level);
if (!py_level) if (!py_level)
goto bad; goto bad;
...@@ -9455,6 +9473,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) { ...@@ -9455,6 +9473,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
name, global_dict, empty_dict, list, py_level, NULL); name, global_dict, empty_dict, list, py_level, NULL);
Py_DECREF(py_level); Py_DECREF(py_level);
} }
}
#else #else
if (level>0) { if (level>0) {
PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); 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