On 5/11/24 12:26 PM, Paul Eggert wrote:
> To reproduce it in a Gnulib repository, run these commands:
>
> git checkout 4de6323d5d20996e51097a90f617cd4404a23eba
> ./gnulib-tool --create-testdir --dir foo -h stdbit
>
> The failing output is as follows. I get this output on Fedora 40 x86-64.
>
> gnulib-tool: warning: module count-leading-zeros doesn't exist
> gnulib-tool: warning: module count-trailing-zeros doesn't exist
> gnulib-tool: warning: module count-one-bits doesn't exist
> Traceback (most recent call last):
> File "/home/eggert/src/gnu/gnulib/./.gnulib-tool.py", line 30, in <module>
> main.main_with_exception_handling()
> File "/home/eggert/src/gnu/gnulib/pygnulib/main.py", line 1371, in
I've applied the attached patch to fix this crash. Since
Glmodulesystem.find() prints a warning/error message upon looking up a
non-existent module returning, returning None here and crashing is
incorrect.
With the module description from that patch and this gnulib-tool fix:
$ gnulib-tool --create-testdir --dir foo -h stdbit
gnulib-tool: warning: module count-leading-zeros doesn't exist
gnulib-tool: warning: module count-trailing-zeros doesn't exist
gnulib-tool: warning: module count-one-bits doesn't exist
Module list with included dependencies (indented):
absolute-header
alignasof
alignasof-tests
And just to confirm that the issue you were running into was due to
the tabs, I added quotes around the module name:
$ gnulib-tool --create-testdir --dir foo -h stdbit
gnulib-tool: warning: module 'count-leading-zeros ' doesn't exist
gnulib-tool: warning: module 'count-trailing-zeros ' doesn't exist
gnulib-tool: warning: module 'count-one-bits ' doesn't exist
Module list with included dependencies (indented):
absolute-header
alignasof
alignasof-tests
assert-h
I'm not sure why gnulib-tool.sh handles the tabs correctly to be
honest...
Collin
From 6c3614c1f3147e85ffcdf12bb9510f55064159c2 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
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
<https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00136.html>.
* 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 <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Filter out dependencies that cannot be found.
+ Reported by Paul Eggert in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00136.html>.
+ * 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 <collin.fu...@gmail.com>
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