Issue #3080: Reindent and simplify import_submodule()
This commit is contained in:
parent
c24c8108b6
commit
9599de5110
|
@ -2779,9 +2779,7 @@ PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals,
|
|||
corresponding entry is not found in sys.modules, Py_None is returned.
|
||||
*/
|
||||
static PyObject *
|
||||
get_parent(PyObject *globals,
|
||||
PyObject **p_name,
|
||||
int level)
|
||||
get_parent(PyObject *globals, PyObject **p_name, int level)
|
||||
{
|
||||
Py_UNICODE name[MAXPATHLEN+1];
|
||||
const Py_ssize_t bufsize = MAXPATHLEN+1;
|
||||
|
@ -3167,7 +3165,10 @@ static PyObject *
|
|||
import_submodule(PyObject *mod, PyObject *subname, PyObject *fullname)
|
||||
{
|
||||
PyObject *modules = PyImport_GetModuleDict();
|
||||
PyObject *m = NULL, *bufobj;
|
||||
PyObject *m = NULL, *bufobj, *path, *loader;
|
||||
char buf[MAXPATHLEN+1];
|
||||
struct filedescr *fdp;
|
||||
FILE *fp;
|
||||
|
||||
/* Require:
|
||||
if mod == None: subname == fullname
|
||||
|
@ -3176,12 +3177,8 @@ import_submodule(PyObject *mod, PyObject *subname, PyObject *fullname)
|
|||
|
||||
if ((m = PyDict_GetItem(modules, fullname)) != NULL) {
|
||||
Py_INCREF(m);
|
||||
return m;
|
||||
}
|
||||
else {
|
||||
PyObject *path, *loader;
|
||||
char buf[MAXPATHLEN+1];
|
||||
struct filedescr *fdp;
|
||||
FILE *fp;
|
||||
|
||||
if (mod == Py_None)
|
||||
path = NULL;
|
||||
|
@ -3216,12 +3213,12 @@ import_submodule(PyObject *mod, PyObject *subname, PyObject *fullname)
|
|||
Py_XDECREF(loader);
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
if (m != NULL && !add_submodule(mod, m, fullname, subname, modules)) {
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
if (!add_submodule(mod, m, fullname, subname, modules)) {
|
||||
Py_XDECREF(m);
|
||||
m = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue