public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Feng, Bob C" <bob.c.feng@intel.com>
To: edk2-devel@lists.01.org
Cc: Yunhua Feng <yunhuax.feng@intel.com>,
	Bob Feng <bob.c.feng@intel.com>,
	Liming Gao <liming.gao@intel.com>,
	Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [Patch 08/33] BaseTools: replace long by int
Date: Tue, 29 Jan 2019 10:05:45 +0800	[thread overview]
Message-ID: <20190129020610.14300-9-bob.c.feng@intel.com> (raw)
In-Reply-To: <20190129020610.14300-1-bob.c.feng@intel.com>

From: Yunhua Feng <yunhuax.feng@intel.com>

replace long by int
Because the long() was not exist in Python3

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py     |  4 ++--
 BaseTools/Source/Python/Common/Misc.py                         |  2 +-
 BaseTools/Source/Python/GenFds/AprioriSection.py               |  2 +-
 BaseTools/Source/Python/GenFds/FdfParser.py                    | 18 +++++++++---------
 BaseTools/Source/Python/GenFds/GenFds.py                       |  8 ++++----
 BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py                 | 10 +++++-----
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py |  4 ++--
 BaseTools/Source/Python/UPT/Parser/DecParser.py                |  6 +++---
 8 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
index edd40a1498..6ddf38fd0d 100644
--- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
+++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
@@ -55,11 +55,11 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object):
             itemIndex = 0
             for item in var_check_tab.validtab:
                 itemIndex += 1
                 realLength += 5
                 for v_data in item.data:
-                    if type(v_data) in (int, long):
+                    if isinstance(v_data, int):
                         realLength += item.StorageWidth
                     else:
                         realLength += item.StorageWidth
                         realLength += item.StorageWidth
                 if (index == len(self.var_check_info)) :
@@ -135,11 +135,11 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object):
 
                 b = pack("=B", item.StorageWidth)
                 Buffer += b
                 realLength += 1
                 for v_data in item.data:
-                    if type(v_data) in (int, long):
+                    if isinstance(v_data, int):
                         b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data)
                         Buffer += b
                         realLength += item.StorageWidth
                     else:
                         b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data[0])
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 9967ac470c..1b8a4bef2e 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1311,11 +1311,11 @@ def CheckPcdDatum(Type, Value):
                           ", FALSE, False, false, 0x0, 0x00, 0" % (Value, Type)
     elif Type in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64]:
         if Value and int(Value, 0) < 0:
             return False, "PCD can't be set to negative value[%s] for datum type [%s]" % (Value, Type)
         try:
-            Value = long(Value, 0)
+            Value = int(Value, 0)
             if Value > MAX_VAL_TYPE[Type]:
                 return False, "Too large PCD value[%s] for datum type [%s]" % (Value, Type)
         except:
             return False, "Invalid value [%s] of type [%s];"\
                           " must be a hexadecimal, decimal or octal in C language format." % (Value, Type)
diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/Source/Python/GenFds/AprioriSection.py
index e7b856a115..55d99320c7 100644
--- a/BaseTools/Source/Python/GenFds/AprioriSection.py
+++ b/BaseTools/Source/Python/GenFds/AprioriSection.py
@@ -95,11 +95,11 @@ class AprioriSection (object):
                         EdkLoggerError("GenFds", RESOURCE_NOT_AVAILABLE,
                                         "INF %s not found in build ARCH %s!" \
                                         % (InfFileName, GenFdsGlobalVariable.ArchList))
 
             GuidPart = Guid.split('-')
-            Buffer.write(pack('I', long(GuidPart[0], 16)))
+            Buffer.write(pack('I', int(GuidPart[0], 16)))
             Buffer.write(pack('H', int(GuidPart[1], 16)))
             Buffer.write(pack('H', int(GuidPart[2], 16)))
 
             for Num in range(2):
                 Char = GuidPart[3][Num*2:Num*2+2]
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 3bcfd2d42a..69cb7de8e5 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1560,11 +1560,11 @@ class FdfParser:
                 Obj.SizePcd = pcdPair
                 self.Profile.PcdDict[pcdPair] = Size
                 self.SetPcdLocalation(pcdPair)
                 FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
                 self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
-            Obj.Size = long(Size, 0)
+            Obj.Size = int(Size, 0)
             return True
 
         if self._IsKeyword("ErasePolarity"):
             if not self._IsToken(TAB_EQUAL_SPLIT):
                 raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
@@ -1595,21 +1595,21 @@ class FdfParser:
                 raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
 
             if not self._GetNextDecimalNumber() and not self._GetNextHexNumber():
                 raise Warning.Expected("address", self.FileName, self.CurrentLineNumber)
 
-            BsAddress = long(self._Token, 0)
+            BsAddress = int(self._Token, 0)
             Obj.BsBaseAddress = BsAddress
 
         if self._IsKeyword("RtBaseAddress"):
             if not self._IsToken(TAB_EQUAL_SPLIT):
                 raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
 
             if not self._GetNextDecimalNumber() and not self._GetNextHexNumber():
                 raise Warning.Expected("address", self.FileName, self.CurrentLineNumber)
 
-            RtAddress = long(self._Token, 0)
+            RtAddress = int(self._Token, 0)
             Obj.RtBaseAddress = RtAddress
 
     ## _GetBlockStatements() method
     #
     #   Get block statements
@@ -1653,21 +1653,21 @@ class FdfParser:
             BlockSizePcd = PcdPair
             self.Profile.PcdDict[PcdPair] = BlockSize
             self.SetPcdLocalation(PcdPair)
             FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
             self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple
-        BlockSize = long(BlockSize, 0)
+        BlockSize = int(BlockSize, 0)
 
         BlockNumber = None
         if self._IsKeyword("NumBlocks"):
             if not self._IsToken(TAB_EQUAL_SPLIT):
                 raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
 
             if not self._GetNextDecimalNumber() and not self._GetNextHexNumber():
                 raise Warning.Expected("block numbers", self.FileName, self.CurrentLineNumber)
 
-            BlockNumber = long(self._Token, 0)
+            BlockNumber = int(self._Token, 0)
 
         Obj.BlockSizeList.append((BlockSize, BlockNumber, BlockSizePcd))
         return True
 
     ## _GetDefineStatements() method
@@ -1772,11 +1772,11 @@ class FdfParser:
             if CurCh in '|\r\n' and PairCount == 0:
                 break
             Expr += CurCh
             self._GetOneChar()
         try:
-            return long(
+            return int(
                 ValueExpression(Expr,
                                 self._CollectMacroPcd()
                                 )(True), 0)
         except Exception:
             self.SetFileBufferPos(StartPos)
@@ -1820,11 +1820,11 @@ class FdfParser:
             self._UndoToken()
             IsRegionPcd = (RegionSizeGuidPattern.match(self._CurrentLine()[self.CurrentOffsetWithinLine:]) or
                            RegionOffsetPcdPattern.match(self._CurrentLine()[self.CurrentOffsetWithinLine:]))
             if IsRegionPcd:
                 RegionObj.PcdOffset = self._GetNextPcdSettings()
-                self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + long(theFd.BaseAddress, 0))
+                self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + int(theFd.BaseAddress, 0))
                 self.SetPcdLocalation(RegionObj.PcdOffset)
                 self._PcdDict['%s.%s' % (RegionObj.PcdOffset[1], RegionObj.PcdOffset[0])] = "0x%x" % RegionObj.Offset
                 FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
                 self.Profile.PcdFileLineDict[RegionObj.PcdOffset] = FileLineTuple
                 if self._IsToken(TAB_VALUE_SPLIT):
@@ -3132,13 +3132,13 @@ class FdfParser:
                         FmpData.HardwareInstance = Value
                 elif Name == 'MONOTONIC_COUNT':
                     if FdfParser._Verify(Name, Value, 'UINT64'):
                         FmpData.MonotonicCount = Value
                         if FmpData.MonotonicCount.upper().startswith('0X'):
-                            FmpData.MonotonicCount = (long)(FmpData.MonotonicCount, 16)
+                            FmpData.MonotonicCount = int(FmpData.MonotonicCount, 16)
                         else:
-                            FmpData.MonotonicCount = (long)(FmpData.MonotonicCount)
+                            FmpData.MonotonicCount = int(FmpData.MonotonicCount)
             if not self._GetNextToken():
                 break
         else:
             self._UndoToken()
 
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 2a5d473e3f..ae5d7fd26d 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -624,13 +624,13 @@ class GenFds(object):
                     FvSpaceInfoList.append((FvName, Total, Used, Free))
 
         GenFdsGlobalVariable.InfLogger('\nFV Space Information')
         for FvSpaceInfo in FvSpaceInfoList:
             Name = FvSpaceInfo[0]
-            TotalSizeValue = long(FvSpaceInfo[1], 0)
-            UsedSizeValue = long(FvSpaceInfo[2], 0)
-            FreeSizeValue = long(FvSpaceInfo[3], 0)
+            TotalSizeValue = int(FvSpaceInfo[1], 0)
+            UsedSizeValue = int(FvSpaceInfo[2], 0)
+            FreeSizeValue = int(FvSpaceInfo[3], 0)
             if UsedSizeValue == TotalSizeValue:
                 Percentage = '100'
             else:
                 Percentage = str((UsedSizeValue + 0.0) / TotalSizeValue)[0:4].lstrip('0.')
 
@@ -653,11 +653,11 @@ class GenFds(object):
                 break
 
         if PcdValue == '':
             return
 
-        Int64PcdValue = long(PcdValue, 0)
+        Int64PcdValue = int(PcdValue, 0)
         if Int64PcdValue == 0 or Int64PcdValue < -1:
             return
 
         TopAddress = 0
         if Int64PcdValue > 0:
diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
index a44781f2e8..c5c99d94ef 100644
--- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
+++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
@@ -139,15 +139,15 @@ if __name__ == '__main__':
     sys.exit(1)
   args.OutputFileName = args.OutputFile
 
   try:
     if args.MonotonicCountStr.upper().startswith('0X'):
-      args.MonotonicCountValue = (long)(args.MonotonicCountStr, 16)
+      args.MonotonicCountValue = int(args.MonotonicCountStr, 16)
     else:
-      args.MonotonicCountValue = (long)(args.MonotonicCountStr)
+      args.MonotonicCountValue = int(args.MonotonicCountStr)
   except:
-    args.MonotonicCountValue = (long)(0)
+    args.MonotonicCountValue = int(0)
 
   if args.Encode:
     #
     # Save signer private cert filename and close private cert file
     #
@@ -249,13 +249,13 @@ if __name__ == '__main__':
     if not args.SignatureSizeStr:
       print("ERROR: please use the option --signature-size to specify the size of the signature data!")
       sys.exit(1)
     else:
       if args.SignatureSizeStr.upper().startswith('0X'):
-        SignatureSize = (long)(args.SignatureSizeStr, 16)
+        SignatureSize = int(args.SignatureSizeStr, 16)
       else:
-        SignatureSize = (long)(args.SignatureSizeStr)
+        SignatureSize = int(args.SignatureSizeStr)
     if SignatureSize < 0:
         print("ERROR: The value of option --signature-size can't be set to negative value!")
         sys.exit(1)
     elif SignatureSize > len(args.InputFileBuffer):
         print("ERROR: The value of option --signature-size is exceed the size of the input file !")
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
index 370ae2e3fa..3a1a2dff00 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
@@ -161,13 +161,13 @@ if __name__ == '__main__':
     sys.exit(Process.returncode)
 
   if args.MonotonicCountStr:
     try:
       if args.MonotonicCountStr.upper().startswith('0X'):
-        args.MonotonicCountValue = (long)(args.MonotonicCountStr, 16)
+        args.MonotonicCountValue = int(args.MonotonicCountStr, 16)
       else:
-        args.MonotonicCountValue = (long)(args.MonotonicCountStr)
+        args.MonotonicCountValue = int(args.MonotonicCountStr)
     except:
         pass
 
   if args.Encode:
     FullInputFileBuffer = args.InputFileBuffer
diff --git a/BaseTools/Source/Python/UPT/Parser/DecParser.py b/BaseTools/Source/Python/UPT/Parser/DecParser.py
index a88b51d055..8f3d60df57 100644
--- a/BaseTools/Source/Python/UPT/Parser/DecParser.py
+++ b/BaseTools/Source/Python/UPT/Parser/DecParser.py
@@ -618,15 +618,15 @@ class _DecPcd(_DecBase):
         #
         Token = TokenList[-1].strip()
         if not IsValidToken(PCD_TOKEN_PATTERN, Token):
             self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN % Token)
         elif not Token.startswith('0x') and not Token.startswith('0X'):
-            if long(Token) > 4294967295:
+            if int(Token) > 4294967295:
                 self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_INT % Token)
-            Token = hex(long(Token))[:-1]
+            Token = hex(int(Token))[:-1]
 
-        IntToken = long(Token, 0)
+        IntToken = int(Token, 0)
         if (Guid, IntToken) in self.TokenMap:
             if self.TokenMap[Guid, IntToken] != CName:
                 self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_UNIQUE%(Token))
         else:
             self.TokenMap[Guid, IntToken] = CName
-- 
2.20.1.windows.1



  parent reply	other threads:[~2019-01-29  2:06 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  2:05 [Patch v2 00/33] BaseTools python3 migration patch set Feng, Bob C
2019-01-29  2:05 ` [Patch 01/33] BaseTool:Rename xrange() to range() Feng, Bob C
2019-01-29  2:05 ` [Patch 02/33] BaseTools:use iterate list to replace the itertools Feng, Bob C
2019-01-29  2:05 ` [Patch 03/33] BaseTools: Rename iteritems to items Feng, Bob C
2019-01-29  2:05 ` [Patch 04/33] BaseTools: replace get_bytes_le() to bytes_le Feng, Bob C
2019-01-29  2:05 ` [Patch 05/33] BaseTools: use OrderedDict instead of sdict Feng, Bob C
2019-01-29  2:05 ` [Patch 06/33] BaseTools: nametuple not have verbose parameter in python3 Feng, Bob C
2019-01-29  2:05 ` [Patch 07/33] BaseTools: Remove unnecessary super function Feng, Bob C
2019-01-29  2:05 ` Feng, Bob C [this message]
2019-01-29  2:05 ` [Patch 09/33] BaseTools:Solve the data sorting problem use python3 Feng, Bob C
2019-01-29  2:05 ` [Patch 10/33] BaseTools: Update argparse arguments since it not have version now Feng, Bob C
2019-01-29  2:05 ` [Patch 11/33] BaseTools:Similar to octal data rectification Feng, Bob C
2019-01-29  2:05 ` [Patch 12/33] BaseTools/UPT:merge UPT Tool use Python2 and Python3 Feng, Bob C
2019-01-29  2:05 ` [Patch 13/33] BaseTools: update Test scripts support python3 Feng, Bob C
2019-01-29  2:05 ` [Patch 14/33] BaseTools/Scripts: Porting PackageDocumentTools code to use Python3 Feng, Bob C
2019-01-29  2:05 ` [Patch 15/33] Basetools: It went wrong when use os.linesep Feng, Bob C
2019-01-29  2:05 ` [Patch 16/33] BaseTools:Fv BaseAddress must set If it not set Feng, Bob C
2019-01-29  2:05 ` [Patch 17/33] BaseTools: Make sure AllPcdList valid Feng, Bob C
2019-01-29  2:05 ` [Patch 18/33] BaseTools:TestTools character encoding issue Feng, Bob C
2019-01-29  2:05 ` [Patch 19/33] BaseTools:Double carriage return inserted from Trim.py on Python3 Feng, Bob C
2019-01-29  2:05 ` [Patch 20/33] BaseTools:File open failed for VPD MapFile Feng, Bob C
2019-01-29  2:05 ` [Patch 21/33] BaseTools: change the Division Operator Feng, Bob C
2019-01-29  2:05 ` [Patch 22/33] BaseTools:There is extra blank line in datalog Feng, Bob C
2019-01-29  2:06 ` [Patch 23/33] BaseTools: Similar to octal data rectification Feng, Bob C
2019-01-29  2:06 ` [Patch 24/33] BaseTools: Update windows and linux run scripts file to use Python3 Feng, Bob C
2019-01-29  2:06 ` [Patch 25/33] BaseTools:Update build tool to print python version information Feng, Bob C
2019-01-29  2:06 ` [Patch 26/33] BaseTools:Linux Python highest version check Feng, Bob C
2019-01-29  2:06 ` [Patch 27/33] BaseTools: Update PYTHON env to PYTHON_COMMAND Feng, Bob C
2019-01-29  2:06 ` [Patch 28/33] BaseTools:Fixed Rsa issue and a set define issue Feng, Bob C
2019-01-29  2:06 ` [Patch 29/33] BaseTools:ord() don't match in py2 and py3 Feng, Bob C
2019-01-29  2:06 ` [Patch 30/33] BaseTools: the list and iterator translation Feng, Bob C
2019-01-29  2:06 ` [Patch 31/33] BaseTools: Handle the bytes and str difference Feng, Bob C
2019-01-29  2:06 ` [Patch 32/33] BaseTools: ECC tool Python3 adaption Feng, Bob C
     [not found]   ` <20190902190211.GZ29255@bivouac.eciton.net>
2019-09-02 19:04     ` [edk2] " Leif Lindholm
2019-09-04  2:10       ` [edk2-devel] " Bob Feng
2019-09-04  8:38         ` Leif Lindholm
2019-09-04  9:12           ` Bob Feng
2019-09-04  9:51             ` Leif Lindholm
2019-09-05  5:39               ` Bob Feng
2019-09-05 10:37                 ` Leif Lindholm
2019-09-05 13:53                   ` Laszlo Ersek
2019-01-29  2:06 ` [Patch v2 33/33] BaseTools: Eot " Feng, Bob C
2019-01-29 13:07 ` [Patch v2 00/33] BaseTools python3 migration patch set Laszlo Ersek
2019-01-30  1:52   ` Gao, Liming
2019-01-30  5:25     ` Feng, Bob C
2019-01-31  8:23       ` Gao, Liming
2019-02-01  3:13         ` Feng, Bob C
2019-02-01  8:50           ` Laszlo Ersek
2019-01-30  2:59   ` Feng, Bob C
  -- strict thread matches above, loose matches on Subject: below --
2019-01-25  4:55 [Patch " Feng, Bob C
2019-01-25  4:56 ` [Patch 08/33] BaseTools: replace long by int Feng, Bob C

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190129020610.14300-9-bob.c.feng@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox