Commit e04894e2 authored by Stefan Behnel's avatar Stefan Behnel

another fix for old-style imports in Py3.3: only try relative imports from within a package

parent cb40a3e6
......@@ -9574,19 +9574,21 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
{
#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))
if (strchr(__Pyx_MODULE_NAME, '.')) {
/* try package relative import first */
PyObject *py_level = PyInt_FromLong(1);
if (!py_level)
goto bad;
PyErr_Clear();
level = 0; /* try absolute import on failure */
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) {
......
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