+ scripts-add-python-3-compatibility-to-spdxcheckpy.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: scripts: add Python 3 compatibility to spdxcheck.py
has been added to the -mm tree.  Its filename is
     scripts-add-python-3-compatibility-to-spdxcheckpy.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/scripts-add-python-3-compatibility-to-spdxcheckpy.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/scripts-add-python-3-compatibility-to-spdxcheckpy.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Jeremy Cline <jcline@xxxxxxxxxx>
Subject: scripts: add Python 3 compatibility to spdxcheck.py

"dict.has_key(key)" on dictionaries has been replaced with "key in dict". 
Additionally, when run under Python 3 some files don't decode with the
default encoding (tested with UTF-8).  To handle that, don't open the file
in text mode and decode text line-by-line, ignoring encoding errors.

This remains compatible with Python 2 and should have no functional
change.

Link: http://lkml.kernel.org/r/20180717190635.29467-1-jcline@xxxxxxxxxx
Signed-off-by: Jeremy Cline <jcline@xxxxxxxxxx>
Acked-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---


diff -puN scripts/spdxcheck.py~scripts-add-python-3-compatibility-to-spdxcheckpy scripts/spdxcheck.py
--- a/scripts/spdxcheck.py~scripts-add-python-3-compatibility-to-spdxcheckpy
+++ a/scripts/spdxcheck.py
@@ -4,6 +4,7 @@
 
 from argparse import ArgumentParser
 from ply import lex, yacc
+import locale
 import traceback
 import sys
 import git
@@ -102,7 +103,7 @@ class id_parser(object):
                 raise ParserException(tok, 'Invalid License ID')
             self.lastid = id
         elif tok.type == 'EXC':
-            if not self.spdx.exceptions.has_key(id):
+            if id not in self.spdx.exceptions:
                 raise ParserException(tok, 'Invalid Exception ID')
             if self.lastid not in self.spdx.exceptions[id]:
                 raise ParserException(tok, 'Exception not valid for license %s' %self.lastid)
@@ -167,6 +168,7 @@ 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
@@ -201,7 +203,8 @@ def scan_git_tree(tree):
             continue
         if not os.path.isfile(el.path):
             continue
-        parser.parse_lines(open(el.path), args.maxlines, el.path)
+        with open(el.path, 'rb') as fd:
+            parser.parse_lines(fd, args.maxlines, el.path)
 
 def scan_git_subtree(tree, path):
     for p in path.strip('/').split('/'):
_

Patches currently in -mm which might be from jcline@xxxxxxxxxx are

scripts-add-python-3-compatibility-to-spdxcheckpy.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux