@@ -322,6 +322,12 @@ get_module_info(ZipImporter *self, PyObject *fullname)
322322 PyObject * path , * fullpath , * item ;
323323 struct st_zip_searchorder * zso ;
324324
325+ if (self -> prefix == NULL ) {
326+ PyErr_SetString (PyExc_ValueError ,
327+ "zipimporter.__init__() wasn't called" );
328+ return MI_ERROR ;
329+ }
330+
325331 subname = get_subname (fullname );
326332 if (subname == NULL )
327333 return MI_ERROR ;
@@ -652,6 +658,12 @@ zipimport_zipimporter_get_data_impl(ZipImporter *self, PyObject *path)
652658 PyObject * toc_entry ;
653659 Py_ssize_t path_start , path_len , len ;
654660
661+ if (self -> archive == NULL ) {
662+ PyErr_SetString (PyExc_ValueError ,
663+ "zipimporter.__init__() wasn't called" );
664+ return NULL ;
665+ }
666+
655667#ifdef ALTSEP
656668 path = _PyObject_CallMethodId ((PyObject * )& PyUnicode_Type , & PyId_replace ,
657669 "OCC" , path , ALTSEP , SEP );
@@ -1476,6 +1488,12 @@ get_module_code(ZipImporter *self, PyObject *fullname,
14761488 PyObject * path , * fullpath = NULL ;
14771489 struct st_zip_searchorder * zso ;
14781490
1491+ if (self -> prefix == NULL ) {
1492+ PyErr_SetString (PyExc_ValueError ,
1493+ "zipimporter.__init__() wasn't called" );
1494+ return NULL ;
1495+ }
1496+
14791497 subname = get_subname (fullname );
14801498 if (subname == NULL )
14811499 return NULL ;
0 commit comments