public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] BaseTools/PatchCheck.py: Fix error when run with Python3
@ 2018-09-05  7:21 Dandan Bi
  2018-09-05 15:02 ` Carsey, Jaben
  0 siblings, 1 reply; 2+ messages in thread
From: Dandan Bi @ 2018-09-05  7:21 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Jaben Carsey, Yonghong Zhu

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1145

Currently run PatchCheck.py with Python3 will meet
following error:
.....
File "PatchCheck.py", line 554, in run_git
return Result[0].decode('utf-8', 'ignore') if Result[0] and
Result[0].find("fatal")!=0 else None
TypeError: a bytes-like object is required, not 'str'

This issue was introduce by commit:5ac4548cdf654.

This patch is to convert the str object of "fatal" to
byte object to fix this failure.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 BaseTools/Scripts/PatchCheck.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py
index 96b3cdf1fd..0b580f3b31 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -549,11 +549,11 @@ class CheckGitCommits:
         cmd += args
         p = subprocess.Popen(cmd,
                      stdout=subprocess.PIPE,
                      stderr=subprocess.STDOUT)
         Result = p.communicate()
-        return Result[0].decode('utf-8', 'ignore') if Result[0] and Result[0].find("fatal")!=0 else None
+        return Result[0].decode('utf-8', 'ignore') if Result[0] and Result[0].find(b"fatal")!=0 else None
 
 class CheckOnePatchFile:
     """Performs a patch check for a single file.
 
     stdin is used when the filename is '-'.
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] BaseTools/PatchCheck.py: Fix error when run with Python3
  2018-09-05  7:21 [patch] BaseTools/PatchCheck.py: Fix error when run with Python3 Dandan Bi
@ 2018-09-05 15:02 ` Carsey, Jaben
  0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2018-09-05 15:02 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Bi, Dandan
> Sent: Wednesday, September 05, 2018 12:21 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Carsey, Jaben
> <jaben.carsey@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
> Subject: [patch] BaseTools/PatchCheck.py: Fix error when run with Python3
> Importance: High
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1145
> 
> Currently run PatchCheck.py with Python3 will meet
> following error:
> .....
> File "PatchCheck.py", line 554, in run_git
> return Result[0].decode('utf-8', 'ignore') if Result[0] and
> Result[0].find("fatal")!=0 else None
> TypeError: a bytes-like object is required, not 'str'
> 
> This issue was introduce by commit:5ac4548cdf654.
> 
> This patch is to convert the str object of "fatal" to
> byte object to fix this failure.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  BaseTools/Scripts/PatchCheck.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Scripts/PatchCheck.py
> b/BaseTools/Scripts/PatchCheck.py
> index 96b3cdf1fd..0b580f3b31 100755
> --- a/BaseTools/Scripts/PatchCheck.py
> +++ b/BaseTools/Scripts/PatchCheck.py
> @@ -549,11 +549,11 @@ class CheckGitCommits:
>          cmd += args
>          p = subprocess.Popen(cmd,
>                       stdout=subprocess.PIPE,
>                       stderr=subprocess.STDOUT)
>          Result = p.communicate()
> -        return Result[0].decode('utf-8', 'ignore') if Result[0] and
> Result[0].find("fatal")!=0 else None
> +        return Result[0].decode('utf-8', 'ignore') if Result[0] and
> Result[0].find(b"fatal")!=0 else None
> 
>  class CheckOnePatchFile:
>      """Performs a patch check for a single file.
> 
>      stdin is used when the filename is '-'.
> --
> 2.14.3.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-05 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-05  7:21 [patch] BaseTools/PatchCheck.py: Fix error when run with Python3 Dandan Bi
2018-09-05 15:02 ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox