/* Return the code object for the module named by 'fullname' from the
   Zip archive as a new reference. */
static PyObject *
get_code_from_data(ZipImporter *self, int ispackage, int isbytecode,
                   time_t mtime, PyObject *toc_entry)
{
    PyObject *data, *code;
    char *modpath;
    char *archive = PyString_AsString(self->archive);

    if (archive == NULL)
        return NULL;

    data = get_data(archive, toc_entry);
    if (data == NULL)
        return NULL;

    modpath = PyString_AsString(PyTuple_GetItem(toc_entry, 0));

    if (isbytecode) {
        code = unmarshal_code(modpath, data, mtime);
    }
    else {
        code = compile_source(modpath, data);
    }
    Py_DECREF(data);
    return code;
}
Example #2
0
/* Return the code object for the module named by 'fullname' from the
   Zip archive as a new reference. */
static PyObject *
get_code_from_data(ZipImporter *self, int ispackage, int isbytecode,
                   time_t mtime, PyObject *toc_entry)
{
    PyObject *data, *modpath, *code;

    data = get_data(self->archive, toc_entry);
    if (data == NULL)
        return NULL;

    modpath = PyTuple_GetItem(toc_entry, 0);
    if (isbytecode)
        code = unmarshal_code(modpath, data, mtime);
    else
        code = compile_source(modpath, data);
    Py_DECREF(data);
    return code;
}