LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] scripts/spdxcheck: make python3 compliant
@ 2018-10-23  7:08 Uwe Kleine-König
  2018-11-07 23:32 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2018-10-23  7:08 UTC (permalink / raw)
  To: Thomas Gleixner, Joe Perches
  Cc: Andrew Morton, kernel, Greg Kroah-Hartman, linux-kernel

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.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 scripts/spdxcheck.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py
index 839e190bbd7a..5056fb3b897d 100755
--- a/scripts/spdxcheck.py
+++ b/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
-- 
2.19.1


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

* Re: [PATCH] scripts/spdxcheck: make python3 compliant
  2018-10-23  7:08 [PATCH] scripts/spdxcheck: make python3 compliant Uwe Kleine-König
@ 2018-11-07 23:32 ` Andrew Morton
  2018-11-08  6:22   ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2018-11-07 23:32 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Thomas Gleixner, Joe Perches, kernel, Greg Kroah-Hartman, linux-kernel

On Tue, 23 Oct 2018 09:08:02 +0200 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

> 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.

I suppose people might want to run spdxcheck.py against (say) 4.19.x
using python3.  So I'll add a cc:stable here, OK?


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

* Re: [PATCH] scripts/spdxcheck: make python3 compliant
  2018-11-07 23:32 ` Andrew Morton
@ 2018-11-08  6:22   ` Uwe Kleine-König
  2018-11-08  7:59     ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2018-11-08  6:22 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Thomas Gleixner, Joe Perches, kernel, Greg Kroah-Hartman, linux-kernel

Hello Andrew,

On Wed, Nov 07, 2018 at 03:32:51PM -0800, Andrew Morton wrote:
> On Tue, 23 Oct 2018 09:08:02 +0200 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> 
> > 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.
> 
> I suppose people might want to run spdxcheck.py against (say) 4.19.x
> using python3.  So I'll add a cc:stable here, OK?

Not sure if people call spdxcheck.py stand-alone. checkpatch.pl calls it
using "python scripts/spdxcheck.py" which AFAICT should still be python2
on all machines. The shebang-line also uses "python" and not "python3".

So for now this is only cosmetic (unless there are distros that install
Python 3 as "python").

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH] scripts/spdxcheck: make python3 compliant
  2018-11-08  6:22   ` Uwe Kleine-König
@ 2018-11-08  7:59     ` Uwe Kleine-König
  0 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2018-11-08  7:59 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Joe Perches, Greg Kroah-Hartman, Thomas Gleixner, linux-kernel, kernel

Hello,

On Thu, Nov 08, 2018 at 07:22:00AM +0100, Uwe Kleine-König wrote:
> On Wed, Nov 07, 2018 at 03:32:51PM -0800, Andrew Morton wrote:
> > On Tue, 23 Oct 2018 09:08:02 +0200 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> > 
> > > 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.
> > 
> > I suppose people might want to run spdxcheck.py against (say) 4.19.x
> > using python3.  So I'll add a cc:stable here, OK?
> 
> Not sure if people call spdxcheck.py stand-alone. checkpatch.pl calls it
> using "python scripts/spdxcheck.py" which AFAICT should still be python2
> on all machines. The shebang-line also uses "python" and not "python3".
> 
> So for now this is only cosmetic (unless there are distros that install
> Python 3 as "python").

I just learned that /usr/bin/python on Arch is Python 3. So this would
indeed be worth to go into 4.19.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23  7:08 [PATCH] scripts/spdxcheck: make python3 compliant Uwe Kleine-König
2018-11-07 23:32 ` Andrew Morton
2018-11-08  6:22   ` Uwe Kleine-König
2018-11-08  7:59     ` Uwe Kleine-König

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git