Hi Bruno,

On 3/14/24 7:38 AM, Bruno Haible wrote:
> This patch looks better than the previous one, that added a
> setSourceBase('lib') invocation. Applied. Thanks!

Yes, that was more just me trying to explain the cause of the issue. I
didn't have a good solution at the time.

This patch was based on the code in the original gnulib-tool. I've
copied many of the comments over as well. They should help cross
reference code to track down any further issues that may occur. :)

>>
>>          sequence = [ True if value == 'true' else value
>>                       for value in sequence ]
>>          sequence = [ value.strip()
>> +                     if type(value) is str else value
>>                       for value in sequence ]
> 
> Is converting 'true' to True a good thing to do here anyway?
> Which invocations of the 'cleaner' function need this?

Oops, I just noticed I formatted the second statement differently than
the first one... Sorry about that.

The invocation of 'cleaner' that gave me an error was on line 171 of
GLConfig. This is during reading of gnulib-cache.m4. Here are the
lines:

            # Find string values
            result = dict(pattern.findall(data))
            values = cleaner([ result.get(key, '')
                               for key in keys ])

I've removed the condition from my sources and can't seem to reproduce
it at the moment. I *think* I can see why it occurred though. I am not
too familiar with the possible/valid statements in gnulib-cache.m4 so
maybe you can better understand.

I believe that there may have been lines like this (where
gl_MACRO_NAME is something we actually care about):

gl_MACRO_NAME([true])
dnl or maybe this?
gl_MACRO_NAME([false])

Then the goal of the conversion would be to turn the m4/shell script
booleans to Python ones. Now that I think about it more, something
like this probably makes more sense:

    sequence = [ value.strip()
                 for value in sequence ]
    sequence = [ True if value == 'true' else value
                 for value in sequence ]

Basically, preform the whitespace cleaning before we deal with type
conversions. It would also allow for handwritten gnulib-cache.m4 files
with strange whitespace like:

gl_MACRO_NAME([ true     ])

Though, I am not sure if gnulib-tool can handle that. Let me know if
you have any other ideas. I can submit a patch later if you'd like.

The 'cleaner' function is only used in GLImport.__init__() which I
would like to cleanup in the future anyways. It is ~300 lines and I
feel it is hard for me to follow. By then I should understand gnulib a
bit more and I will revisit 'cleaner'.

Collin

Reply via email to