Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:56628 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725819AbeKQJXC (ORCPT ); Sat, 17 Nov 2018 04:23:02 -0500 Date: Fri, 16 Nov 2018 15:08:43 -0800 From: akpm@linux-foundation.org To: akpm@linux-foundation.org, gregkh@linuxfoundation.org, joe@perches.com, mm-commits@vger.kernel.org, stable@vger.kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, u.kleine-koenig@pengutronix.de Subject: [patch 14/18] scripts/spdxcheck.py: make python3 compliant Message-ID: <20181116230843.WVkKfMXjF%akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: stable-owner@vger.kernel.org List-ID: From: Uwe Kleine-König 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 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 Cc: Thomas Gleixner Cc: Joe Perches Cc: Greg Kroah-Hartman Cc: Signed-off-by: Andrew Morton --- --- 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 _