1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| [import.c] PyObject* PyImport_ImportModuleLevel(char* name, PyObject* globals, PyObject* locals,PyObject* fromlist, int level){ PyObject* result; lock_import(); result = import_module_level(name,globals,locals,fromlist,level); unlock_import(); return result; }
[import.c] static PyObject* import_module_level(char* name,PyObject* globals, PyObject* locals, PyObject* fromlist, int level){ char buf[MAXPATHLEN + 1]; int buflen = 0; PyObject* parent,*head,*next,*tail; parent = get_parent(globals,buf,&buflen,level); head = load_next(parent, Py_None, &name, buf, &buflen); tail = head; while(name){ next = load_next(tail,tail,&name,buf,&buflen); tail = next; }
if(fromlist != NULL){ if(fromlist == Py_None || !PyObject_IsTrue(fromlist)) fromlist = NULL; }
if(fromlist == NULL){ return head; }
if(!ensure_fromlist(tail,fromlist.buf,buflen,0)){ return NULL; }
return tail; }
|