* [patch 14/18] scripts/spdxcheck.py: make python3 compliant
@ 2018-11-16 23:08 akpm
2018-11-16 23:48 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: akpm @ 2018-11-16 23:08 UTC (permalink / raw)
To: akpm, gregkh, joe, mm-commits, stable, tglx, torvalds, u.kleine-koenig
From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Subject: scripts/spdxcheck.py: make python3 compliant
Without this change the following happens when using Python3 (3.6.6):
$ echo "GPL-2.0" | python3 scripts/spdxcheck.py -
FAIL: 'str' object has no attribute 'decode'
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 253, in <module>
parser.parse_lines(sys.stdin, args.maxlines, '-')
File "scripts/spdxcheck.py", line 171, in parse_lines
line = line.decode(locale.getpreferredencoding(False), errors='ignore')
AttributeError: 'str' object has no attribute 'decode'
So as the line is already a string, there is no need to decode it and
the line can be dropped.
/usr/bin/python on Arch is Python 3. So this would indeed be worth
going into 4.19.
Link: http://lkml.kernel.org/r/20181023070802.22558-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Joe Perches <joe@perches.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
--- a/scripts/spdxcheck.py~scripts-spdxcheck-make-python3-compliant
+++ a/scripts/spdxcheck.py
@@ -168,7 +168,6 @@ class id_parser(object):
self.curline = 0
try:
for line in fd:
- line = line.decode(locale.getpreferredencoding(False), errors='ignore')
self.curline += 1
if self.curline > maxlines:
break
_
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 14/18] scripts/spdxcheck.py: make python3 compliant
2018-11-16 23:08 [patch 14/18] scripts/spdxcheck.py: make python3 compliant akpm
@ 2018-11-16 23:48 ` Joe Perches
2018-11-17 15:44 ` Uwe Kleine-König
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2018-11-16 23:48 UTC (permalink / raw)
To: akpm, gregkh, mm-commits, stable, tglx, torvalds, u.kleine-koenig
On Fri, 2018-11-16 at 15:08 -0800, akpm@linux-foundation.org wrote:
> From: Uwe Kleine-K�nig <u.kleine-koenig@pengutronix.de>
> Subject: scripts/spdxcheck.py: make python3 compliant
>
> Without this change the following happens when using Python3 (3.6.6):
>
> $ echo "GPL-2.0" | python3 scripts/spdxcheck.py -
> FAIL: 'str' object has no attribute 'decode'
> Traceback (most recent call last):
> File "scripts/spdxcheck.py", line 253, in <module>
> parser.parse_lines(sys.stdin, args.maxlines, '-')
> File "scripts/spdxcheck.py", line 171, in parse_lines
> line = line.decode(locale.getpreferredencoding(False), errors='ignore')
> AttributeError: 'str' object has no attribute 'decode'
>
> So as the line is already a string, there is no need to decode it and
> the line can be dropped.
>
> /usr/bin/python on Arch is Python 3. So this would indeed be worth
> going into 4.19.
OK, I tested this (and it works fine) but found I needed to
install a couple of extra packages that I didn't already have
for the default python3 installation.
python3-ply and python3-git
Perhaps that should be mentioned in some requirements doc.
In fact, scripts/spdxcheck.py is not mentioned in any doc file.
> Link: http://lkml.kernel.org/r/20181023070802.22558-1-u.kleine-koenig@pengutronix.de
> Signed-off-by: Uwe Kleine-K�nig <u.kleine-koenig@pengutronix.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Joe Perches <joe@perches.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
>
> --- a/scripts/spdxcheck.py~scripts-spdxcheck-make-python3-compliant
> +++ a/scripts/spdxcheck.py
> @@ -168,7 +168,6 @@ class id_parser(object):
> self.curline = 0
> try:
> for line in fd:
> - line = line.decode(locale.getpreferredencoding(False), errors='ignore')
> self.curline += 1
> if self.curline > maxlines:
> break
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 14/18] scripts/spdxcheck.py: make python3 compliant
2018-11-16 23:48 ` Joe Perches
@ 2018-11-17 15:44 ` Uwe Kleine-König
0 siblings, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2018-11-17 15:44 UTC (permalink / raw)
To: Joe Perches; +Cc: akpm, gregkh, mm-commits, stable, tglx, torvalds
On Fri, Nov 16, 2018 at 03:48:09PM -0800, Joe Perches wrote:
> On Fri, 2018-11-16 at 15:08 -0800, akpm@linux-foundation.org wrote:
> > From: Uwe Kleine-K�nig <u.kleine-koenig@pengutronix.de>
> > Subject: scripts/spdxcheck.py: make python3 compliant
> >
> > Without this change the following happens when using Python3 (3.6.6):
> >
> > $ echo "GPL-2.0" | python3 scripts/spdxcheck.py -
> > FAIL: 'str' object has no attribute 'decode'
> > Traceback (most recent call last):
> > File "scripts/spdxcheck.py", line 253, in <module>
> > parser.parse_lines(sys.stdin, args.maxlines, '-')
> > File "scripts/spdxcheck.py", line 171, in parse_lines
> > line = line.decode(locale.getpreferredencoding(False), errors='ignore')
> > AttributeError: 'str' object has no attribute 'decode'
> >
> > So as the line is already a string, there is no need to decode it and
> > the line can be dropped.
> >
> > /usr/bin/python on Arch is Python 3. So this would indeed be worth
> > going into 4.19.
>
> OK, I tested this (and it works fine) but found I needed to
> install a couple of extra packages that I didn't already have
> for the default python3 installation.
>
> python3-ply and python3-git
>
> Perhaps that should be mentioned in some requirements doc.
>
> In fact, scripts/spdxcheck.py is not mentioned in any doc file.
In fact I tried to run spdxcheck with python3 becaus I didn't have
python-ply and python-git which don't come with python2 :-)
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K�nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-18 2:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16 23:08 [patch 14/18] scripts/spdxcheck.py: make python3 compliant akpm
2018-11-16 23:48 ` Joe Perches
2018-11-17 15:44 ` Uwe Kleine-König
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.