data_smart: Avoid exceptions for non string data
PATCH 1/1 data_smart: Avoid exceptions for non string data
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.
--- lib/bb/data_smart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/data_smart.py +1 -1
@@ -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):
Signature · 1 line
2.32.0
Hi Richard,
Quoted 19 lines · Richard Purdie
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 iterableWe inject True values as an internal sentinel to the datastore, fix this codepath to handle it.
Signed-off-by Richard Purdie <[email protected]>--- lib/bb/data_smart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/bb/data_smart.py +0
-0
lib/bb/data_smart.py class DataSmart(MutableMapping): · line 1007
Quoted 5 lines
lib/bb/data_smart.py +1
-1@@ -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
Quoted 17 lines · Quentin Schulz
Hi Richard,
Quoted 14 lines · Richard Purdie
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 iterableWe inject True values as an internal sentinel to the datastore, fix this codepath to handle it.
Signed-off-by Richard Purdie <[email protected]>--- lib/bb/data_smart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
lib/bb/data_smart.py class DataSmart(MutableMapping): · line 1007
Quoted 10 lines
lib/bb/data_smart.py +1
-1@@ -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.
Quoted 2 lines
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