cpython: 07a615a8f9ad (original) (raw)

--- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -1,6 +1,7 @@ import sys import os import marshal +import importlib import importlib.util import struct import time @@ -48,6 +49,7 @@ test_pyc = make_pyc(test_co, NOW, len(te TESTMOD = "ziptestmodule" TESTPACK = "ziptestpackage" TESTPACK2 = "ziptestpackage2" +TEMP_DIR = os.path.abspath("junk95142") TEMP_ZIP = os.path.abspath("junk95142.zip") pyc_file = importlib.util.cache_from_source(TESTMOD + '.py') @@ -77,45 +79,64 @@ class UncompressedZipImportTestCase(Impo def setUp(self): # We're reusing the zip archive path, so we must clear the

+

+

+

+

def testAFakeZlib(self): # @@ -201,7 +222,9 @@ class UncompressedZipImportTestCase(Impo packdir + TESTMOD + pyc_ext: (NOW, test_pyc)} self.doTest(pyc_ext, files, TESTPACK, TESTMOD)

@@ -209,6 +232,167 @@ class UncompressedZipImportTestCase(Impo packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)} self.doTest(pyc_ext, files, TESTPACK, TESTPACK2, TESTMOD)

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ def testZipImporterMethods(self): packdir = TESTPACK + os.sep packdir2 = packdir + TESTPACK2 + os.sep @@ -231,7 +415,7 @@ class UncompressedZipImportTestCase(Impo mod = zi.load_module(TESTPACK) self.assertEqual(zi.get_filename(TESTPACK), mod.file)

@@ -241,8 +425,8 @@ class UncompressedZipImportTestCase(Impo mod_path = packdir2 + TESTMOD mod_name = module_path_to_dotted_name(mod_path)

@@ -289,13 +473,13 @@ class UncompressedZipImportTestCase(Impo mod_path = TESTPACK2 + os.sep + TESTMOD mod_name = module_path_to_dotted_name(mod_path)

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -44,6 +44,8 @@ Core and Builtins Library ------- +- Issue #17633: Improve zipimport's support for namespace packages. +

--- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -324,17 +324,14 @@ get_module_info(ZipImporter *self, PyObj } typedef enum {

} find_loader_result; -/* The guts of "find_loader" and "find_module". Return values:

+/* The guts of "find_loader" and "find_module". */ static find_loader_result find_loader(ZipImporter *self, PyObject *fullname, PyObject **namespace_portion) @@ -349,21 +346,34 @@ find_loader(ZipImporter self, PyObject if (mi == MI_NOT_FOUND) { / Not a module or regular package. See if this is a directory, and therefore possibly a portion of a namespace package. */

+

+