Hi Bruno,

On 4/10/24 5:07 AM, Bruno Haible wrote:
> The reason is a different order of the languages in LINGUAS.
> gnulib-tool.sh uses
>   LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
> which produces sorted output. Whereas GLImport.py uses
>   for file in os.listdir(joinpath(destdir, pobase))
> which lacks the sorting.

I don't seem to be able to run into this sorting issue on my system.
But from the os.listdir documentation, "The list is in arbitrary
order" [1]. So what is there now seems incomplete.

Can you test the attached patch for me? It is just an addition of a
sorted() call, which should hopefully fix it.

[1] https://docs.python.org/3/library/os.html#os.listdir

Collin
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index fdca884a08..46beb7e2a6 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -1199,9 +1199,9 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
             if not self.config['dryrun']:
                 tmpfile = self.assistant.tmpfilename(basename)
                 data = '# Set of available languages.\n'
-                files = [ constants.subend('.po', '', file)
-                          for file in os.listdir(joinpath(destdir, pobase))
-                          if file.endswith('.po') ]
+                files = sorted([ constants.subend('.po', '', file)
+                                 for file in os.listdir(joinpath(destdir, pobase))
+                                 if file.endswith('.po') ])
                 data += lines_to_multiline(files)
                 with codecs.open(tmpfile, 'wb', 'UTF-8') as file:
                     file.write(data)

Reply via email to