From 6494cd76aeec4a71f7039b054cc92a5ec74b33a2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 12 Mar 2024 21:50:21 -0400 Subject: [PATCH] Bypass ZipFile.namelist in glob. Closes #106. --- tests/test_complexity.py | 2 +- zipp/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_complexity.py b/tests/test_complexity.py index d2adcf1..e2445e1 100644 --- a/tests/test_complexity.py +++ b/tests/test_complexity.py @@ -85,7 +85,7 @@ def test_glob_depth(self): max_n=100, min_n=1, ) - assert best <= big_o.complexities.Quadratic + assert best <= big_o.complexities.Linear @pytest.mark.flaky def test_glob_width(self): diff --git a/zipp/__init__.py b/zipp/__init__.py index a1b9884..da9687c 100644 --- a/zipp/__init__.py +++ b/zipp/__init__.py @@ -399,7 +399,8 @@ def glob(self, pattern): prefix = re.escape(self.at) tr = Translator(seps='/') matches = re.compile(prefix + tr.translate(pattern)).fullmatch - return map(self._next, filter(matches, self.root.namelist())) + names = (data.filename for data in self.root.filelist) + return map(self._next, filter(matches, names)) def rglob(self, pattern): return self.glob(f'**/{pattern}')