diff mbox series

[Unstable/Lunar] UBUNTU: [Packaging] annotations: Use non-greedy policy match

Message ID 20230202161411.442006-1-juerg.haefliger@canonical.com
State New
Headers show
Series [Unstable/Lunar] UBUNTU: [Packaging] annotations: Use non-greedy policy match | expand

Commit Message

Juerg Haefliger Feb. 2, 2023, 4:14 p.m. UTC
A single line can contain both policy and note sections, so use non-greedy
matches for all sections.

Otherwise, a line like:

CONFIG_FOO   policy<{'arm64': 'm'}> note<LP: #123456>

results in:

Traceback (most recent call last):
  File "debian/scripts/misc/kconfig/annotations.py", line 80, in _parse_body
    entry['policy'] |= literal_eval(m.group(1))
  File "/usr/lib/python3.10/ast.py", line 64, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
  File "/usr/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    {'arm64': 'm'}> note<LP: #123456
                           ^
SyntaxError: invalid syntax

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
---
 debian/scripts/misc/kconfig/annotations.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Juerg Haefliger Feb. 3, 2023, 7:18 a.m. UTC | #1
Just realized that the new annotations file can't handle single line configs
properly. Need to fix that first.

...Juerg


> A single line can contain both policy and note sections, so use non-greedy
> matches for all sections.
> 
> Otherwise, a line like:
> 
> CONFIG_FOO   policy<{'arm64': 'm'}> note<LP: #123456>
> 
> results in:
> 
> Traceback (most recent call last):
>   File "debian/scripts/misc/kconfig/annotations.py", line 80, in _parse_body
>     entry['policy'] |= literal_eval(m.group(1))
>   File "/usr/lib/python3.10/ast.py", line 64, in literal_eval
>     node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
>   File "/usr/lib/python3.10/ast.py", line 50, in parse
>     return compile(source, filename, mode, flags,
>   File "<unknown>", line 1
>     {'arm64': 'm'}> note<LP: #123456
>                            ^
> SyntaxError: invalid syntax
> 
> Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
> ---
>  debian/scripts/misc/kconfig/annotations.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py
> index 84dd4d26e6af..af963b76355b 100644
> --- a/debian/scripts/misc/kconfig/annotations.py
> +++ b/debian/scripts/misc/kconfig/annotations.py
> @@ -74,7 +74,7 @@ class Annotation(Config):
>                              entry = self.config[conf]
>                          else:
>                              entry = {'policy': {}}
> -                        m = re.match(r'.*policy<(.*)>', line)
> +                        m = re.match(r'.*policy<(.*?)>', line)
>                          if m:
>                              entry['policy'] |= literal_eval(m.group(1))
>                          else:
diff mbox series

Patch

diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py
index 84dd4d26e6af..af963b76355b 100644
--- a/debian/scripts/misc/kconfig/annotations.py
+++ b/debian/scripts/misc/kconfig/annotations.py
@@ -74,7 +74,7 @@  class Annotation(Config):
                             entry = self.config[conf]
                         else:
                             entry = {'policy': {}}
-                        m = re.match(r'.*policy<(.*)>', line)
+                        m = re.match(r'.*policy<(.*?)>', line)
                         if m:
                             entry['policy'] |= literal_eval(m.group(1))
                         else: