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