From 6c3614c1f3147e85ffcdf12bb9510f55064159c2 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Sat, 11 May 2024 21:45:12 -0700 Subject: [PATCH] gnulib-tool.py: Filter out dependencies that cannot be found. Reported by Paul Eggert in . * pygnulib/GLModuleSystem.py (GLModule.getDependenciesWithConditions): Reorder conditionals to avoid duplicate checks. Filter out None from the gathered dependencies when gathering module dependencies. Let GLModuleSystem.find() warn instead of crashing. --- ChangeLog | 10 ++++++++++ pygnulib/GLModuleSystem.py | 15 ++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a159f518dc..6154ef2bc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2024-05-11 Collin Funk + + gnulib-tool.py: Filter out dependencies that cannot be found. + Reported by Paul Eggert in + . + * pygnulib/GLModuleSystem.py (GLModule.getDependenciesWithConditions): + Reorder conditionals to avoid duplicate checks. Filter out None from the + gathered dependencies when gathering module dependencies. Let + GLModuleSystem.find() warn instead of crashing. + 2024-05-11 Collin Funk execinfo: Add tests. diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index b25779d62e..872961ba91 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -538,17 +538,18 @@ def getDependenciesWithConditions(self) -> list[tuple[GLModule, str | None]]: result = [] for line in lines: match = pattern.search(line) - if match: - module = line[0 : match.start()] + if not match: + module_name = line + condition = None + else: + module_name = line[0 : match.start()] condition = line[match.end() :] condition = subend(']', '', condition) - else: - module = line - condition = None - if module != '': if condition == 'true': condition = None - result.append(tuple([self.modulesystem.find(module), condition])) + module = self.modulesystem.find(module_name) + if module is not None: + result.append((module, condition)) self.cache['dependenciesWithCond'] = result return self.cache['dependenciesWithCond'] -- 2.45.0