From b62cbfb787e1ac594fce618a1a9c86cabc63d54b Mon Sep 17 00:00:00 2001 From: zhijufan Date: Tue, 11 Sep 2018 10:49:34 +0800 Subject: 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 Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan Reviewed-by: Yonghong Zhu --- BaseTools/Source/Python/Common/Misc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'BaseTools/Source/Python/Common/Misc.py') 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 -- cgit v1.2.3