diff mbox

kbuild: Update to diffconfig to support python 2.6 and greater

Message ID 3029888.QLGxfpIyIk@comanche (mailing list archive)
State New, archived
Headers show

Commit Message

Mike Pagano Aug. 13, 2013, 9:32 p.m. UTC
Modification of the diffconfig script to support python versions 2.6 and 
greater. 

Note that Linux distributions are starting to deprecate python versions < 2.5

Diffconfig is a utility script for comparing kernel configuration files.

Signed-off-by: Mike Pagano <mpagano@gentoo.org>
---
 scripts/diffconfig | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

Comments

Michal Marek Aug. 15, 2013, 3:49 p.m. UTC | #1
On 13.8.2013 23:32, Mike Pagano wrote:
> Modification of the diffconfig script to support python versions 2.6 and 
> greater. 
> 
> Note that Linux distributions are starting to deprecate python versions < 2.5

Dumb question - The original script works for me with python 2.7.3 from
openSUSE. Does python have some strict mode that would show the problems
you are fixing? It's always good to mention the actual error to the
changelog.


> Diffconfig is a utility script for comparing kernel configuration files.

Again, superfluous information.

Thanks,
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek Aug. 15, 2013, 4 p.m. UTC | #2
On 15.8.2013 17:49, Michal Marek wrote:
> On 13.8.2013 23:32, Mike Pagano wrote:
>> Modification of the diffconfig script to support python versions 2.6 and 
>> greater. 
>>
>> Note that Linux distributions are starting to deprecate python versions < 2.5
> 
> Dumb question - The original script works for me with python 2.7.3 from
> openSUSE. Does python have some strict mode that would show the problems
> you are fixing? It's always good to mention the actual error to the
> changelog.

I now tried the patched version on a system with python 2.4.2 and it
fails with:
  File "../diffconfig2", line 103
    except IOError as e:
                    ^
SyntaxError: invalid syntax

The original version works fine with both 2.4.2 and 2.7.3. So should the
changelog actually read "drop support for python < 2.5"? What do we gain
by this change?

Thanks,
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/scripts/diffconfig b/scripts/diffconfig
index 33c696f..131d7b2 100755
--- a/scripts/diffconfig
+++ b/scripts/diffconfig
@@ -10,7 +10,7 @@ 
 import sys, os
 
 def usage():
-    print """Usage: diffconfig [-h] [-m] [<config1> <config2>]
+    print("""Usage: diffconfig [-h] [-m] [<config1> <config2>]
 
 Diffconfig is a simple utility for comparing two .config files.
 Using standard diff to compare .config files often includes extraneous and
@@ -33,7 +33,7 @@  Example usage:
  EXT2_FS  y -> n
  LOG_BUF_SHIFT  14 -> 16
  PRINTK_TIME  n -> y
-"""
+""")
     sys.exit(0)
 
 # returns a dictionary of name/value pairs for config items in the file
@@ -54,23 +54,26 @@  def print_config(op, config, value, new_value):
     if merge_style:
         if new_value:
             if new_value=="n":
-                print "# CONFIG_%s is not set" % config
+                print("# CONFIG_%s is not set" % config)
             else:
-                print "CONFIG_%s=%s" % (config, new_value)
+                print("CONFIG_%s=%s" % (config, new_value))
     else:
         if op=="-":
-            print "-%s %s" % (config, value)
+            print("-%s %s" % (config, value))
         elif op=="+":
-            print "+%s %s" % (config, new_value)
+            print("+%s %s" % (config, new_value))
         else:
-            print " %s %s -> %s" % (config, value, new_value)
+            print(" %s %s -> %s" % (config, value, new_value))
 
 def main():
     global merge_style
 
+    a = {}
+    b = {}
+
     # parse command line args
     if ("-h" in sys.argv or "--help" in sys.argv):
-	usage()
+        usage()
 
     merge_style = 0
     if "-m" in sys.argv:
@@ -79,13 +82,13 @@  def main():
 
     argc = len(sys.argv)
     if not (argc==1 or argc == 3):
-        print "Error: incorrect number of arguments or unrecognized option"
+        print("Error: incorrect number of arguments or unrecognized option")
         usage()
 
     if argc == 1:
         # if no filenames given, assume .config and .config.old
         build_dir=""
-        if os.environ.has_key("KBUILD_OUTPUT"):
+        if "KBUILD_OUTPUT" in os.environ:
             build_dir = os.environ["KBUILD_OUTPUT"]+"/"
 
         configa_filename = build_dir + ".config.old"
@@ -95,11 +98,11 @@  def main():
         configb_filename = sys.argv[2]
 
     try:
-        a = readconfig(file(configa_filename))
-        b = readconfig(file(configb_filename))
-    except IOError,(errno, strerror):
-		print "I/O error(%s: %s)\n" % (errno, strerror)
-		usage()
+        a = readconfig(open(configa_filename))
+        b = readconfig(open(configb_filename))
+    except IOError as e:
+        print("I/O error({0}): {1}\n".format(e.errno, e.strerror))
+        usage()
 
     # print items in a but not b (accumulate, sort and print)
     old = []
@@ -125,8 +128,7 @@  def main():
 
     # now print items in b but not in a
     # (items from b that were in a were removed above)
-    new = b.keys()
-    new.sort()
+    new = sorted(b.keys())
     for config in new:
         print_config("+", config, None, b[config])