Catch TypeError exception when do int(value)
authorlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Mon, 1 Feb 2010 09:21:34 +0000 (09:21 +0000)
committerlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Mon, 1 Feb 2010 09:21:34 +0000 (09:21 +0000)
git-svn-id: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/trunk/BaseTools@1830 c2973edb-eda0-4c78-bc6a-9341b269661f

Source/Python/AutoGen/GenC.py

index 1ced3a7..add26cb 100644 (file)
@@ -963,10 +963,15 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
         Unicode = False
         ValueNumber = 0
         if Pcd.DatumType in ['UINT64', 'UINT32', 'UINT16', 'UINT8']:
-            if Value.upper().startswith('0X'):
-                ValueNumber = int (Value, 16)
-            else:
-                ValueNumber = int (Value)
+            try:
+                if Value.upper().startswith('0X'):
+                    ValueNumber = int (Value, 16)
+                else:
+                    ValueNumber = int (Value)
+            except:
+                EdkLogger.error("build", AUTOGEN_ERROR,
+                                "PCD value is not valid dec or hex number for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
+                                ExtraData="[%s]" % str(Info))
             if Pcd.DatumType == 'UINT64':
                 if ValueNumber < 0:
                     EdkLogger.error("build", AUTOGEN_ERROR,