Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3280947imm; Sun, 16 Sep 2018 14:15:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY+6uDOtKIa1+pfBJCG2fFZvOUl1V3O/PUdo6tyM/pHcNxmcTo1EWCcObKE8ulonwMQZtXc X-Received: by 2002:a17:902:4403:: with SMTP id k3-v6mr21728856pld.243.1537132548967; Sun, 16 Sep 2018 14:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537132548; cv=none; d=google.com; s=arc-20160816; b=LnPP+hNQwfWtG2cXiOUC2achYB0i1cGw+ApHIHPL8ZDVdn7sWitz3S41QUEYTJCojG jXc6K5BJB+2dy3ZwuClusgnia8wGTdaJM8Qto1ALG4MyHrcF0izQYEIfQ6T+N7NjTv+V uDW3XJtKCApcYHLctNVyTdOJ8EiFpY6anLVnNX5jfVEMABGUI3xAN7RYV0fJB1TMO3Nj 6RTXlkVnUPzjz7Z2/9QVQBnvmp3o+E9TDxQznt3PbElaMaLTkxrXSrgL3RgvR94EKQyq cXTKa6UYDMUotF7CJFsXuNhybXqXMYKMVvEKYYiKwREsMmjdnlxowsMqq/BAHGXCV2Ny EQEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:from; bh=DwpcnW5yxdRNzJfjhvVPPIh11hYEVihXa2vIdo8zB7g=; b=lo0SZDnZJdWjbw75zJHegqJE5P1a4wLdFJXi22gX5eTuTyr2BzWVpZ9DhTIOgTqhN9 cNPqj5PvmxZq669Ynd7WTISYd6yQuvn3MAr0sXqzuwkgaGoANXo9vpTt1e3rgqiTw2yi bzuX9Q1L6CBq9UeaY7CSsAVwJL9Q8bVPEgBkLy8ubmGREfNPi300fIO4+bgAGIkdsodX afGbsJTf8CnB3Dgz+OjVjDOc84K1a3Wpagf7MLHTSIOlAuAXJeHciQjYawst/3yMbIsv lWKNRKBxpiDrx8ZkB02UhDk2I6R+a+QdIe3M0jhJaD+ouhBsExsukSLu8/WnUsq53r99 wUhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=DvIs5Aai; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3-v6si13193131pgu.248.2018.09.16.14.15.33; Sun, 16 Sep 2018 14:15:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=DvIs5Aai; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728460AbeIQCh0 (ORCPT + 99 others); Sun, 16 Sep 2018 22:37:26 -0400 Received: from ned.t-8ch.de ([212.47.237.191]:38768 "EHLO ned.t-8ch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728128AbeIQChZ (ORCPT ); Sun, 16 Sep 2018 22:37:25 -0400 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1537132384; bh=cGDDdjfYQ05YghVXadQrS3siG3+vlOrYileDnCJKo04=; h=From:To:Cc:Subject:Date:From; b=DvIs5AaiXZxTO/JEw5zZsQ3+pQgD6GvMsIe4xTJiYYBAEz8KRY7Ejws1eps+qjeR9 IbWACWpJ3437FKzL+dCgwCyPH90QwzGwN4p0R5DtIH3vBlO/thK8A3GegRVL4LLfUH zO3WgfRG7YbRwb18sF1ljTZ5q+xHrtVnOzGRiaFo= To: Thomas Gleixner , Andrew Morton , Jonathan Corbet , Joe Perches , Jeremy Cline , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [PATCH] scripts/spdxcheck.py: improve Python 3 compat Date: Sun, 16 Sep 2018 23:12:41 +0200 Message-Id: <20180916211241.7836-1-linux@weissschuh.net> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When reading lines from a text-mode fd strings are returned. These can not be decoded again into strings, breaking the logic in parser. Just make sure all files are opened in binary mode on Python 3, so the current logic keeps working. This remains compatible with Python 2 and should have no functional change. Signed-off-by: Thomas Weißschuh --- scripts/spdxcheck.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py index 839e190bbd7a..8f472f995d70 100755 --- a/scripts/spdxcheck.py +++ b/scripts/spdxcheck.py @@ -250,12 +250,15 @@ if __name__ == '__main__': try: if len(args.path) and args.path[0] == '-': - parser.parse_lines(sys.stdin, args.maxlines, '-') + parser.parse_lines( + # always get the binary fd + getattr(sys.stdin, 'buffer', sys.stdin), + args.maxlines, '-') else: if args.path: for p in args.path: if os.path.isfile(p): - parser.parse_lines(open(p), args.maxlines, p) + parser.parse_lines(open(p, 'rb'), args.maxlines, p) elif os.path.isdir(p): scan_git_subtree(repo.head.reference.commit.tree, p) else: -- 2.18.0