import.c:load_source_module() confusion
I'm working on a patch implementing PEP 304 behavior and am a little confused about how import.c:load_source_module() works. When a source module is found, it's called. The first thing it does is check for and try to read a .pyc/.pyo file: cpathname = make_compiled_pathname(pathname, buf, (size_t)MAXPATHLEN + 1); if (cpathname != NULL && (fpc = check_compiled_module(pathname, mtime, cpathname))) { co = read_compiled_module(cpathname, fpc); fclose(fpc); if (co == NULL) return NULL; if (Py_VerboseFlag) PySys_WriteStderr("import %s # precompiled from %s\n", name, cpathname); pathname = cpathname; } I don't understand why it returns when co is NULL. Shouldn't it compile the source code (later on in the function) and return the code object generated from that? It seems like it would be rare in most circumstances (unless your name is Paul DuBois ;-) for read_compiled_module() to return NULL (corrupt marshal data or a .pyc containing something other than a code object). Skip
participants (2)
-
Guido van Rossum
-
Skip Montanaro