BaseTools:Coding problems caused by special characters

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1670

During BaseTools compiling under Chinese or Japanese
language Windows, python exception occurring.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xbd
in position 3528: ordinal not in range(128)

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Fan, ZhijuX
2019-03-29 13:53:40 +08:00
committed by Feng, Bob C
parent 58742d7945
commit 1c27ec4236
5 changed files with 10 additions and 10 deletions

View File

@ -94,7 +94,7 @@ def SignPayloadSignTool (Payload, ToolPath, PfxFile):
if Process.returncode != 0:
shutil.rmtree (TempDirectoryName)
print (Result[1].decode())
print (Result[1].decode(encoding='utf-8', errors='ignore'))
raise ValueError ('GenerateCapsule: error: signtool failed.')
#
@ -132,12 +132,12 @@ def SignPayloadOpenSsl (Payload, ToolPath, SignerPrivateCertFile, OtherPublicCer
try:
Process = subprocess.Popen (Command, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)
Result = Process.communicate(input = Payload)
Signature = Result[0]
Signature = Result[0].decode(encoding='utf-8', errors='ignore')
except:
raise ValueError ('GenerateCapsule: error: can not run openssl.')
if Process.returncode != 0:
print (Result[1].decode())
print (Result[1].decode(encoding='utf-8', errors='ignore'))
raise ValueError ('GenerateCapsule: error: openssl failed.')
return Signature
@ -186,7 +186,7 @@ def VerifyPayloadOpenSsl (Payload, CertData, ToolPath, SignerPrivateCertFile, Ot
if Process.returncode != 0:
shutil.rmtree (TempDirectoryName)
print (Result[1].decode())
print (Result[1].decode(encoding='utf-8', errors='ignore'))
raise ValueError ('GenerateCapsule: error: openssl failed.')
shutil.rmtree (TempDirectoryName)