Skip to content

Commit e4b7fc3

Browse files
arichardsonjrtc27
andcommitted
mtree: Fix incorrect early return in walk()
Co-authored-by: Jessica Clarke <[email protected]>
1 parent aa01249 commit e4b7fc3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pycheribuild/mtree.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ def glob(self, pattern: str, *, case_sensitive=False) -> Iterator[MtreePath]:
201201
def _walk(self, top, prefix) -> "Iterator[tuple[MtreePath, list[str], list[str]]]":
202202
split = self._split_key(top)
203203
if split is not None:
204-
yield from self.children[split[0]]._walk(split[1], prefix / split[0])
204+
if split[0] in self.children:
205+
yield from self.children[split[0]]._walk(split[1], prefix / split[0])
205206
return
206207
if self.entry is not None and self.entry.attributes["type"] != "dir":
207208
return
@@ -217,8 +218,6 @@ def _walk(self, top, prefix) -> "Iterator[tuple[MtreePath, list[str], list[str]]
217218
yield from v._walk(MtreePath(), prefix)
218219

219220
def walk(self, top) -> "Iterator[tuple[MtreePath, list[str], list[str]]]":
220-
if top not in self.children:
221-
return iter([])
222221
return self._walk(top, MtreePath())
223222

224223

0 commit comments

Comments
 (0)