cpython: 10f09881320d (original) (raw)

--- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -42,16 +42,10 @@ struct _zipimporter { static PyObject *ZipImportError; static PyObject *zip_directory_cache = NULL; -static PyObject zip_stat_cache = NULL; -/ posix.fstat or nt.fstat function. Used due to posixmodule.c's

@@ -132,38 +126,12 @@ zipimporter_init(ZipImporter *self, PyOb PyObject *files; files = PyDict_GetItemString(zip_directory_cache, path); if (files == NULL) {

-

-

@@ -451,12 +419,11 @@ static PyObject * zipimporter_get_data(PyObject *obj, PyObject *args) { ZipImporter *self = (ZipImporter *)obj;

#ifdef ALTSEP char *p, buf[MAXPATHLEN + 1]; #endif

- toc_entry = PyDict_GetItemString(self->files, path); if (toc_entry == NULL) { PyErr_SetFromErrnoWithFilename(PyExc_IOError, path);

} static PyObject * @@ -513,8 +473,7 @@ zipimporter_get_source(PyObject *obj, Py { ZipImporter *self = (ZipImporter *)obj; PyObject *toc_entry;

- toc_entry = PyDict_GetItemString(self->files, path);

/* we have the module, but no source */

} PyDoc_STRVAR(doc_find_module, @@ -710,139 +662,7 @@ get_long(unsigned char buf) { } /

-

-

-

-} - -/* Return 1 if objects a and b fail a Py_EQ test for an attr. */ -static int -compare_obj_attr_strings(PyObject *obj_a, PyObject *obj_b, char *attr_name) -{

-} - -/*

-

-

-

-

-

-} - -/*

@@ -883,18 +703,28 @@ read_directory(FILE *fp, char *archive) } strcpy(path, archive);

+ if (fseek(fp, -22, SEEK_END) == -1) {

@@ -963,15 +793,18 @@ read_directory(FILE *fp, char *archive) goto error; count++; }

@@ -1008,13 +841,14 @@ get_decompress_func(void) return decompress; } -/* Given a FILE* to a Zip file and a toc_entry, return the (uncompressed) +/* Given a path to a Zip file and a toc_entry, return the (uncompressed) data as a new reference. */ static PyObject * -get_data(FILE *fp, char *archive, PyObject *toc_entry) +get_data(char *archive, PyObject *toc_entry) { PyObject *raw_data, *data = NULL, *decompress; char *buf;

+ /* Check to make sure the local file header is correct */ if (fseek(fp, file_offset, 0) == -1) {

@@ -1260,13 +1107,17 @@ get_mtime_of_source(ZipImporter self, c / Return the code object for the module named by 'fullname' from the Zip archive as a new reference. */ static PyObject * -get_code_from_data(char *archive, FILE *fp, int ispackage,

+get_code_from_data(ZipImporter *self, int ispackage, int isbytecode,

{ PyObject *data, *code; char *modpath;

+

@@ -1301,19 +1152,12 @@ get_module_code(ZipImporter *self, char for (zso = zip_searchorder; *zso->suffix; zso++) { PyObject *code = NULL;

strcpy(path + len, zso->suffix); if (Py_VerboseFlag > 1) PySys_WriteStderr("# trying %s%c%s\n", PyString_AsString(self->archive), SEP, path); -

- toc_entry = PyDict_GetItemString(self->files, path); if (toc_entry != NULL) { time_t mtime = 0; @@ -1324,10 +1168,9 @@ get_module_code(ZipImporter *self, char mtime = get_mtime_of_source(self, path); if (p_ispackage != NULL) *p_ispackage = ispackage;

@@ -1339,7 +1182,6 @@ get_module_code(ZipImporter *self, char PyTuple_GetItem(toc_entry, 0)); return code; }

@@ -1415,31 +1254,4 @@ initzipimport(void) if (PyModule_AddObject(mod, "_zip_directory_cache", zip_directory_cache) < 0) return; -

-

}