]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools:Updata the output encoding of the Popen function
authorBob Feng <bob.c.feng@intel.com>
Tue, 16 Jul 2019 09:14:08 +0000 (17:14 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 1 Aug 2019 07:36:48 +0000 (15:36 +0800)
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2015

Not all output works in utf-8, so change the encoding to
the default

This patch is going to fix that issue.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/Common/VpdInfoFile.py
BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
BaseTools/Source/Python/Workspace/DscBuildData.py

index 27dbdace425226223dd9b0c4c16be9d9e257e288..1caa184eb923d046938e25f51ae0daafbcf2b4b3 100644 (file)
@@ -1087,7 +1087,7 @@ def ParseFieldValue (Value):
             p.stderr.close()\r
         if err:\r
             raise BadExpression("DevicePath: %s" % str(err))\r
-        out = out.decode(encoding='utf-8', errors='ignore')\r
+        out = out.decode()\r
         Size = len(out.split())\r
         out = ','.join(out.split())\r
         return '{' + out + '}', Size\r
index bc69a9010da87d99a1492f145e6b1f2b035a9f7c..4249b9f899e7728516cf01ac42db8fb405535e69 100644 (file)
@@ -243,7 +243,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
     except Exception as X:\r
         EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X))\r
     (out, error) = PopenObject.communicate()\r
-    print(out.decode(encoding='utf-8', errors='ignore'))\r
+    print(out.decode())\r
     while PopenObject.returncode is None :\r
         PopenObject.wait()\r
 \r
index 5630df55dfacf34345dc124c8da02ab2e7a9a9e4..5d4c3a8599ff9640c6ecc85d626f1ca5cd6e8d53 100644 (file)
@@ -116,7 +116,7 @@ if __name__ == '__main__':
   if Process.returncode != 0:\r
     print('ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH')\r
     sys.exit(Process.returncode)\r
-  print(Version[0].decode(encoding='utf-8', errors='ignore'))\r
+  print(Version[0].decode())\r
 \r
   #\r
   # Read input file into a buffer and save input filename\r
index f9aed2bf866ebbdd28bf9c98e3f33a31d77490a2..6c9b8c464e4db5643355a9c2e74ed4698750c7b3 100644 (file)
@@ -78,7 +78,7 @@ if __name__ == '__main__':
   if Process.returncode != 0:\r
     print('ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH')\r
     sys.exit(Process.returncode)\r
-  print(Version[0].decode(encoding='utf-8', errors='ignore'))\r
+  print(Version[0].decode())\r
 \r
   args.PemFileName = []\r
 \r
@@ -119,7 +119,7 @@ if __name__ == '__main__':
     # Extract public key from private key into STDOUT\r
     #\r
     Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
-    PublicKeyHexString = Process.communicate()[0].decode(encoding='utf-8', errors='ignore').split(b'=')[1].strip()\r
+    PublicKeyHexString = Process.communicate()[0].decode().split(b'=')[1].strip()\r
     if Process.returncode != 0:\r
       print('ERROR: Unable to extract public key from private key')\r
       sys.exit(Process.returncode)\r
@@ -132,7 +132,7 @@ if __name__ == '__main__':
     #\r
     Process = subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslCommand), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     Process.stdin.write (PublicKey)\r
-    PublicKeyHash = PublicKeyHash + Process.communicate()[0].decode(encoding='utf-8', errors='ignore')\r
+    PublicKeyHash = PublicKeyHash + Process.communicate()[0].decode()\r
     if Process.returncode != 0:\r
       print('ERROR: Unable to extract SHA 256 hash of public key')\r
       sys.exit(Process.returncode)\r
index 985f8775259d21ba08fa0266b804738c71ce74ec..620e48fa7f5945d1c829f701e3aac0469d0379e4 100644 (file)
@@ -1735,7 +1735,7 @@ class DscBuildData(PlatformBuildClassObject):
         except:\r
             EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % Command)\r
         Result = Process.communicate()\r
-        return Process.returncode, Result[0].decode(encoding='utf-8', errors='ignore'), Result[1].decode(encoding='utf-8', errors='ignore')\r
+        return Process.returncode, Result[0].decode(), Result[1].decode()\r
 \r
     @staticmethod\r
     def IntToCString(Value, ValueSize):\r