A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2003-January/032635.html below:

[Python-Dev] import.c:load_source_module() confusion

[Python-Dev] import.c:load_source_module() confusion [Python-Dev] import.c:load_source_module() confusionSkip Montanaro skip@pobox.com
Fri, 31 Jan 2003 08:32:07 -0600
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



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4