Commit 90354468 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

--HG--
extra : transplant_source : %DF7%9D%BC%D2%07%B6%92v5N%7E%D2%3B%9AJ%95d_%B3
parent f0674993
......@@ -9450,19 +9450,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