]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/Expression.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / Common / Expression.py
index 19ea13b7fb2d63a920c274391e2f2947cfa57356..07ca039a9cf328a4e63185a7db047d5e56636a95 100644 (file)
@@ -2,13 +2,7 @@
 # This file is used to parse and evaluate expression in directive or PCD value.\r
 #\r
 # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution.    The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 ## Import Modules\r
 #\r
@@ -439,6 +433,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
@@ -912,7 +913,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