framework/config: fix issue with string values
Commit Message
From: Owen Hilyard <ohilyard@iol.unh.edu>
String values were ran through 'eval' like everything else as part of
parsing config files. This will work the first time if there are quotes
around the value, but if the --update-expected flag is passed, it will
re-write the config file without quotes around the string value. This
then cause an error when the value is 'eval'ed again, since it will now
be evaluated as a variable.
Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
---
framework/config.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
> -----Original Message-----
> From: ohilyard@iol.unh.edu <ohilyard@iol.unh.edu>
> Sent: 2021年6月25日 21:08
> To: Tu, Lijuan <lijuan.tu@intel.com>
> Cc: dts@dpdk.org; Owen Hilyard <ohilyard@iol.unh.edu>
> Subject: [PATCH] framework/config: fix issue with string values
>
> From: Owen Hilyard <ohilyard@iol.unh.edu>
>
> String values were ran through 'eval' like everything else as part of parsing
> config files. This will work the first time if there are quotes around the value, but
> if the --update-expected flag is passed, it will re-write the config file without
> quotes around the string value. This then cause an error when the value is
> 'eval'ed again, since it will now be evaluated as a variable.
>
> Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
Applied, thanks
@@ -147,7 +147,10 @@ class SuiteConf(UserConf):
conf = dict(case_confs)
for key, data_string in list(conf.items()):
- case_cfg[key] = eval(data_string)
+ try:
+ case_cfg[key] = eval(data_string)
+ except NameError: # happens when data_string is actually a string, not an int, bool or dict
+ case_cfg[key] = data_string
return case_cfg