* [PATCH 1/1] BaseTools: explicitly import decode_header PatchCheck.py @ 2020-04-21 15:42 Leif Lindholm 2020-04-27 15:37 ` [edk2-devel] " Liming Gao 0 siblings, 1 reply; 4+ messages in thread From: Leif Lindholm @ 2020-04-21 15:42 UTC (permalink / raw) To: devel; +Cc: Bob Feng, Liming Gao On Debian 10 (Buster), when running PatchCheck.py with python2, a backtrace is printed, starting from: File "../edk2/BaseTools/Scripts/PatchCheck.py", line 595, in find_patch_pieces parts = email.header.decode_header(pmail.get('subject')) AttributeError: 'module' object has no attribute 'header' When using python3, this backtrace does not appear. Explicitly importing decode_header resolves this for python2 and does not appear to cause any issues with python3. Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Leif Lindholm <leif@nuviainc.com> --- I'm pretty sure this used to work with python 2, but I'm not sure when it stopped... BaseTools/Scripts/PatchCheck.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py index 13da6967785d..675ce273e830 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -19,6 +19,8 @@ import re import subprocess import sys +from email.header import decode_header + class Verbose: SILENT, ONELINE, NORMAL = range(3) level = NORMAL -- 2.20.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] BaseTools: explicitly import decode_header PatchCheck.py 2020-04-21 15:42 [PATCH 1/1] BaseTools: explicitly import decode_header PatchCheck.py Leif Lindholm @ 2020-04-27 15:37 ` Liming Gao 2020-04-27 15:56 ` Leif Lindholm 0 siblings, 1 reply; 4+ messages in thread From: Liming Gao @ 2020-04-27 15:37 UTC (permalink / raw) To: devel@edk2.groups.io, leif@nuviainc.com; +Cc: Feng, Bob C Lefi: Is email.header built-in lib? If this change doesn't require user to install the additional python library, I am OK with change. > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Leif Lindholm > Sent: Tuesday, April 21, 2020 11:42 PM > To: devel@edk2.groups.io > Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com> > Subject: [edk2-devel] [PATCH 1/1] BaseTools: explicitly import decode_header PatchCheck.py > > On Debian 10 (Buster), when running PatchCheck.py with python2, a > backtrace is printed, starting from: > > File "../edk2/BaseTools/Scripts/PatchCheck.py", line 595, in find_patch_pieces > parts = email.header.decode_header(pmail.get('subject')) > AttributeError: 'module' object has no attribute 'header' > > When using python3, this backtrace does not appear. > > Explicitly importing decode_header resolves this for python2 and does not > appear to cause any issues with python3. > > Cc: Bob Feng <bob.c.feng@intel.com> > Cc: Liming Gao <liming.gao@intel.com> > Signed-off-by: Leif Lindholm <leif@nuviainc.com> > --- > > I'm pretty sure this used to work with python 2, > but I'm not sure when it stopped... > > BaseTools/Scripts/PatchCheck.py | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py > index 13da6967785d..675ce273e830 100755 > --- a/BaseTools/Scripts/PatchCheck.py > +++ b/BaseTools/Scripts/PatchCheck.py > @@ -19,6 +19,8 @@ import re > import subprocess > import sys > > +from email.header import decode_header > + > class Verbose: > SILENT, ONELINE, NORMAL = range(3) > level = NORMAL > -- > 2.20.1 > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] BaseTools: explicitly import decode_header PatchCheck.py 2020-04-27 15:37 ` [edk2-devel] " Liming Gao @ 2020-04-27 15:56 ` Leif Lindholm 2020-04-28 11:35 ` Bob Feng 0 siblings, 1 reply; 4+ messages in thread From: Leif Lindholm @ 2020-04-27 15:56 UTC (permalink / raw) To: Gao, Liming; +Cc: devel@edk2.groups.io, Feng, Bob C Hi Liming, Yes - this is part of https://docs.python.org/3/library/email.header.html (or for Python 2, https://docs.python.org/2/library/email.header.html). Someone with better python knowledge than me may be able to explain why the implicit import is required for Python 2 (at least in my setup) but not Python 3. / Leif On Mon, Apr 27, 2020 at 15:37:45 +0000, Gao, Liming wrote: > Lefi: > Is email.header built-in lib? If this change doesn't require user to install the additional python library, I am OK with change. > > > -----Original Message----- > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Leif Lindholm > > Sent: Tuesday, April 21, 2020 11:42 PM > > To: devel@edk2.groups.io > > Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com> > > Subject: [edk2-devel] [PATCH 1/1] BaseTools: explicitly import decode_header PatchCheck.py > > > > On Debian 10 (Buster), when running PatchCheck.py with python2, a > > backtrace is printed, starting from: > > > > File "../edk2/BaseTools/Scripts/PatchCheck.py", line 595, in find_patch_pieces > > parts = email.header.decode_header(pmail.get('subject')) > > AttributeError: 'module' object has no attribute 'header' > > > > When using python3, this backtrace does not appear. > > > > Explicitly importing decode_header resolves this for python2 and does not > > appear to cause any issues with python3. > > > > Cc: Bob Feng <bob.c.feng@intel.com> > > Cc: Liming Gao <liming.gao@intel.com> > > Signed-off-by: Leif Lindholm <leif@nuviainc.com> > > --- > > > > I'm pretty sure this used to work with python 2, > > but I'm not sure when it stopped... > > > > BaseTools/Scripts/PatchCheck.py | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py > > index 13da6967785d..675ce273e830 100755 > > --- a/BaseTools/Scripts/PatchCheck.py > > +++ b/BaseTools/Scripts/PatchCheck.py > > @@ -19,6 +19,8 @@ import re > > import subprocess > > import sys > > > > +from email.header import decode_header > > + > > class Verbose: > > SILENT, ONELINE, NORMAL = range(3) > > level = NORMAL > > -- > > 2.20.1 > > > > > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] BaseTools: explicitly import decode_header PatchCheck.py 2020-04-27 15:56 ` Leif Lindholm @ 2020-04-28 11:35 ` Bob Feng 0 siblings, 0 replies; 4+ messages in thread From: Bob Feng @ 2020-04-28 11:35 UTC (permalink / raw) To: devel@edk2.groups.io, leif@nuviainc.com, Gao, Liming Hi Leif, I check the email/__init__.py, the difference between py2 and py3 is that py2 email/__init__.py list both "Header" and "header" as email module public interface. I tried to change the line 595, from email.header.XXX to email.Header.XXX. the issue is gone for py2. Looks the "Header" hide the "header". Since the decode_header is the interface of the email.header module, I think the patch can be simplify as - import email + import email.header Thanks, Bob -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Leif Lindholm Sent: Monday, April 27, 2020 11:56 PM To: Gao, Liming <liming.gao@intel.com> Cc: devel@edk2.groups.io; Feng, Bob C <bob.c.feng@intel.com> Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools: explicitly import decode_header PatchCheck.py Hi Liming, Yes - this is part of https://docs.python.org/3/library/email.header.html (or for Python 2, https://docs.python.org/2/library/email.header.html). Someone with better python knowledge than me may be able to explain why the implicit import is required for Python 2 (at least in my setup) but not Python 3. / Leif On Mon, Apr 27, 2020 at 15:37:45 +0000, Gao, Liming wrote: > Lefi: > Is email.header built-in lib? If this change doesn't require user to install the additional python library, I am OK with change. > > > -----Original Message----- > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Leif > > Lindholm > > Sent: Tuesday, April 21, 2020 11:42 PM > > To: devel@edk2.groups.io > > Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming > > <liming.gao@intel.com> > > Subject: [edk2-devel] [PATCH 1/1] BaseTools: explicitly import > > decode_header PatchCheck.py > > > > On Debian 10 (Buster), when running PatchCheck.py with python2, a > > backtrace is printed, starting from: > > > > File "../edk2/BaseTools/Scripts/PatchCheck.py", line 595, in find_patch_pieces > > parts = email.header.decode_header(pmail.get('subject')) > > AttributeError: 'module' object has no attribute 'header' > > > > When using python3, this backtrace does not appear. > > > > Explicitly importing decode_header resolves this for python2 and > > does not appear to cause any issues with python3. > > > > Cc: Bob Feng <bob.c.feng@intel.com> > > Cc: Liming Gao <liming.gao@intel.com> > > Signed-off-by: Leif Lindholm <leif@nuviainc.com> > > --- > > > > I'm pretty sure this used to work with python 2, but I'm not sure > > when it stopped... > > > > BaseTools/Scripts/PatchCheck.py | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/BaseTools/Scripts/PatchCheck.py > > b/BaseTools/Scripts/PatchCheck.py index 13da6967785d..675ce273e830 > > 100755 > > --- a/BaseTools/Scripts/PatchCheck.py > > +++ b/BaseTools/Scripts/PatchCheck.py > > @@ -19,6 +19,8 @@ import re > > import subprocess > > import sys > > > > +from email.header import decode_header > > + > > class Verbose: > > SILENT, ONELINE, NORMAL = range(3) > > level = NORMAL > > -- > > 2.20.1 > > > > > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-28 11:35 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-04-21 15:42 [PATCH 1/1] BaseTools: explicitly import decode_header PatchCheck.py Leif Lindholm 2020-04-27 15:37 ` [edk2-devel] " Liming Gao 2020-04-27 15:56 ` Leif Lindholm 2020-04-28 11:35 ` Bob Feng
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox