]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/Expression.py
BaseTools: change the Division Operator in the expression
[mirror_edk2.git] / BaseTools / Source / Python / Common / Expression.py
index 9a98236a8c3414326739423ea04e3fd1a479cd61..5e4e66a10e7ba05c01e379c6a11055ea5a5cc32f 100644 (file)
@@ -425,6 +425,13 @@ class ValueExpression(BaseExpression):
                 else:\r
                     Val = Val3\r
                 continue\r
+            #\r
+            # PEP 238 -- Changing the Division Operator\r
+            # x/y to return a reasonable approximation of the mathematical result of the division ("true division")\r
+            # x//y to return the floor ("floor division")\r
+            #\r
+            if Op == '/':\r
+                Op = '//'\r
             try:\r
                 Val = self.Eval(Op, Val, EvalFunc())\r
             except WrnExpression as Warn:\r
@@ -898,7 +905,7 @@ class ValueExpressionEx(ValueExpression):
                     if TmpValue.bit_length() == 0:\r
                         PcdValue = '{0x00}'\r
                     else:\r
-                        for I in range((TmpValue.bit_length() + 7) / 8):\r
+                        for I in range((TmpValue.bit_length() + 7) // 8):\r
                             TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))\r
                         PcdValue = '{' + ', '.join(TmpList) + '}'\r
                 except:\r