diff options
author | zhijufan <zhijux.fan@intel.com> | 2018-09-11 10:49:34 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-09-12 10:57:00 +0800 |
commit | b62cbfb787e1ac594fce618a1a9c86cabc63d54b (patch) | |
tree | 5cac0cfa4746dccde3fab38bd6eaffd38cde0859 /BaseTools/Source/Python/Common | |
parent | 5c9ac43f47865bb9b13608fd7ae1d39ab73ef397 (diff) | |
download | edk2-b62cbfb787e1ac594fce618a1a9c86cabc63d54b.tar.gz edk2-b62cbfb787e1ac594fce618a1a9c86cabc63d54b.tar.bz2 edk2-b62cbfb787e1ac594fce618a1a9c86cabc63d54b.zip |
BaseTools: Report error for incorrect hex value format
The case is user use 0x1} as a hex value for Pcd, it directly cause
tool report traceback info. This patch add more error info.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Common')
-rw-r--r-- | BaseTools/Source/Python/Common/Misc.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 2cf9574326..430bf6bcda 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1414,7 +1414,10 @@ def ParseFieldValue (Value): Value = Value.strip().strip('"')
return ParseDevPathValue(Value)
if Value.lower().startswith('0x'):
- Value = int(Value, 16)
+ try:
+ Value = int(Value, 16)
+ except:
+ raise BadExpression("invalid hex value: %s" % Value)
if Value == 0:
return 0, 1
return Value, (Value.bit_length() + 7) / 8
|