Message ID | 20220222113813.3213276-1-richard.purdie@linuxfoundation.org |
---|---|
State | Accepted, archived |
Commit | 3b88562d87ac94725c1a683c859c2a6a3287d173 |
Headers | show |
Series | data_smart: Avoid exceptions for non string data | expand |
Hi Richard, On 2/22/22 12:38, Richard Purdie wrote: > File "scripts/lib/checklayer/__init__.py", line 49, in _get_layer_collections > ldata.expandVarref('LAYERDIR') > File "build/bitbake/lib/bb/data_smart.py", line 1007, in expandVarref > if referrervalue and ref in referrervalue: > TypeError: argument of type 'bool' is not iterable > > We inject True values as an internal sentinel to the datastore, fix > this codepath to handle it. > > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> > --- > lib/bb/data_smart.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py > index e7047d79ca..8d3825f398 100644 > --- a/lib/bb/data_smart.py > +++ b/lib/bb/data_smart.py > @@ -1004,7 +1004,7 @@ class DataSmart(MutableMapping): > value = self.getVar(variable, False) > for key in keys: > referrervalue = self.getVar(key, False) > - if referrervalue and ref in referrervalue: > + if referrervalue and isinstance(referrervalue, str) and ref in referrervalue: I assume we can remove the referrervalue check? If it was about protecting from None value, isinstance() will return False. If it was about '' string.. it was never needed in the first place since it's ref in '' which would always return false (provided ref is never '' too, but that was not covered by the current condition anyways). Otherwise... can't we just have referrervalue = self.getVar(key, False) or '' ? so that it's always a string? Cheers, Quentin
On Tue, 2022-02-22 at 12:50 +0100, Quentin Schulz wrote: > Hi Richard, > > On 2/22/22 12:38, Richard Purdie wrote: > > File "scripts/lib/checklayer/__init__.py", line 49, in _get_layer_collections > > ldata.expandVarref('LAYERDIR') > > File "build/bitbake/lib/bb/data_smart.py", line 1007, in expandVarref > > if referrervalue and ref in referrervalue: > > TypeError: argument of type 'bool' is not iterable > > > > We inject True values as an internal sentinel to the datastore, fix > > this codepath to handle it. > > > > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> > > --- > > lib/bb/data_smart.py | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py > > index e7047d79ca..8d3825f398 100644 > > --- a/lib/bb/data_smart.py > > +++ b/lib/bb/data_smart.py > > @@ -1004,7 +1004,7 @@ class DataSmart(MutableMapping): > > value = self.getVar(variable, False) > > for key in keys: > > referrervalue = self.getVar(key, False) > > - if referrervalue and ref in referrervalue: > > + if referrervalue and isinstance(referrervalue, str) and ref in referrervalue: > > I assume we can remove the referrervalue check? If it was about > protecting from None value, isinstance() will return False. If it was > about '' string.. it was never needed in the first place since it's ref > in '' which would always return false (provided ref is never '' too, but > that was not covered by the current condition anyways). True, we could have done that. > Otherwise... can't we just have referrervalue = self.getVar(key, False) > or '' ? so that it's always a string? No, since getVar could return a bool or int. Cheers, Richard
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index e7047d79ca..8d3825f398 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -1004,7 +1004,7 @@ class DataSmart(MutableMapping): value = self.getVar(variable, False) for key in keys: referrervalue = self.getVar(key, False) - if referrervalue and ref in referrervalue: + if referrervalue and isinstance(referrervalue, str) and ref in referrervalue: self.setVar(key, referrervalue.replace(ref, value)) def localkeys(self):
File "scripts/lib/checklayer/__init__.py", line 49, in _get_layer_collections ldata.expandVarref('LAYERDIR') File "build/bitbake/lib/bb/data_smart.py", line 1007, in expandVarref if referrervalue and ref in referrervalue: TypeError: argument of type 'bool' is not iterable We inject True values as an internal sentinel to the datastore, fix this codepath to handle it. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- lib/bb/data_smart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)