summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/pkgutil.py3
-rw-r--r--Lib/test/test_pkgutil.py6
2 files changed, 7 insertions, 2 deletions
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py
index 27dd887..0ec6ec5 100644
--- a/Lib/pkgutil.py
+++ b/Lib/pkgutil.py
@@ -318,8 +318,7 @@ try:
from zipimport import zipimporter
def iter_zipimport_modules(importer, prefix=''):
- dirlist = zipimport._zip_directory_cache[importer.archive].keys()
- dirlist.sort()
+ dirlist = sorted(zipimport._zip_directory_cache[importer.archive])
_prefix = importer.prefix
plen = len(_prefix)
yielded = {}
diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py
index 169ef66..f69af5a 100644
--- a/Lib/test/test_pkgutil.py
+++ b/Lib/test/test_pkgutil.py
@@ -74,6 +74,12 @@ class PkgutilTests(unittest.TestCase):
self.assertEqual(res1, RESOURCE_DATA)
res2 = pkgutil.get_data(pkg, 'sub/res.txt')
self.assertEqual(res2, RESOURCE_DATA)
+
+ names = []
+ for loader, name, ispkg in pkgutil.iter_modules([zip_file]):
+ names.append(name)
+ self.assertEqual(names, ['test_getdata_zipfile'])
+
del sys.path[0]
del sys.modules[pkg]