<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14917</bug_id>
          
          <creation_ts>2022-09-26 10:05:19 +0000</creation_ts>
          <short_desc>Syntax error when using dicts in ${@...}</short_desc>
          <delta_ts>2022-11-10 15:32:37 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.99</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Enrico Scholz">enrico.scholz</reporter>
          <assigned_to name="Mark">mark.asselstine</assigned_to>
          <cc>mark.asselstine</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>94069</commentid>
    <comment_count>0</comment_count>
    <who name="Enrico Scholz">enrico.scholz</who>
    <bug_when>2022-09-26 10:05:19 +0000</bug_when>
    <thetext>```
LICENSE = &quot;CLOSED&quot;

IDX = &quot;green&quot;
VAL = &quot;${@{ &apos;green&apos;: 1, &apos;blue&apos;: 2 }[d.getVar(&apos;IDX&apos;)]}&quot;
```

fails to expand with

```
expansion of VAL threw ExpansionError: Failure expanding variable VAL, expression was ${@{ &apos;green&apos;: 1, &apos;blue&apos;: 2 }[d.getVar(&apos;IDX&apos;)]} which triggered exception SyntaxError: &apos;{&apos; was never closed (Var &lt;VAL&gt;, line 1)
```


A workaround could be something like

```
VAL = &quot;${@dict((lambda x: zip(x,x))(iter([ \
    &apos;green&apos;, 1, \
    &apos;blue&apos;,  2, \
    ])))[d.getVar(&apos;IDX&apos;)]}&quot;
```

but it is non trivial, difficulty to understand and error prone.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94334</commentid>
    <comment_count>1</comment_count>
    <who name="Mark">mark.asselstine</who>
    <bug_when>2022-11-03 00:47:24 +0000</bug_when>
    <thetext>The regex in use will not handle nested curly brackets, the first close curly it sees will end the match, even if it passes over an open curly along the way. It should be possible to ignore a single set of nested curly brackets so I will see if I can derive something that will do the trick. Attempting to have multiple levels of nesting would involve moving to something else, like pyparsing, so we will leave that to a later exercise, should a usecase pop up for it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94392</commentid>
    <comment_count>2</comment_count>
    <who name="Mark">mark.asselstine</who>
    <bug_when>2022-11-10 15:32:37 +0000</bug_when>
    <thetext>Fixed by commit 94e49b9b9e409c29eb04603b1305d96ebe661a4b [data_smart: allow python snippets to include a dictionary]. Enrico please feel free to try it out and raise any issues.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>