public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Meelis Roos <mroos@linux.ee>
To: linux-ia64@vger.kernel.org
Subject: [PATCH] ia64: fix unwcheck.py for python3
Date: Fri, 06 Jun 2014 11:38:02 +0000	[thread overview]
Message-ID: <alpine.SOC.1.00.1406061434000.8408@math.ut.ee> (raw)

In Gentoo, Python3 is the default Python and our unwcheck.py breaks with 
Python 3. Fix it:

 * Close % substitutions of strings in parens to avoid syntax errors
 * make long code portable as per 
   http://python3porting.com/differences.html#long - define long for 
   Python3 and use long(0) instead of 0L for Python2.

Tested to still work with Python2 too (at least it omits no errors).

Signed-off-by: Meelis Roos <mroos@linux.ee>

diff --git a/arch/ia64/scripts/unwcheck.py b/arch/ia64/scripts/unwcheck.py
index 2bfd941..679c02d 100644
--- a/arch/ia64/scripts/unwcheck.py
+++ b/arch/ia64/scripts/unwcheck.py
@@ -15,9 +15,12 @@ import re
 import sys
 
 if len(sys.argv) != 2:
-    print "Usage: %s FILE" % sys.argv[0]
+    print ("Usage: %s FILE" % sys.argv[0])
     sys.exit(2)
 
+if sys.version > '3':
+    long = int # dummy conversion for Python 3
+
 readelf = os.getenv("READELF", "readelf")
 
 start_pattern = re.compile("<([^>]*)>: \[0x([0-9a-f]+)-0x([0-9a-f]+)\]")
@@ -28,7 +31,7 @@ def check_func (func, slots, rlen_sum):
         global num_errors
         num_errors += 1
         if not func: func = "[%#x-%#x]" % (start, end)
-        print "ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum)
+        print ("ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum))
     return
 
 num_funcs = 0
@@ -45,7 +48,7 @@ for line in os.popen("%s -u %s" % (readelf, sys.argv[1])):
         start = long(m.group(2), 16)
         end   = long(m.group(3), 16)
         slots = 3 * (end - start) / 16
-        rlen_sum = 0L
+        rlen_sum = long(0)
         num_funcs += 1
     else:
         m = rlen_pattern.match(line)
@@ -54,11 +57,11 @@ for line in os.popen("%s -u %s" % (readelf, sys.argv[1])):
 check_func(func, slots, rlen_sum)
 
 if num_errors = 0:
-    print "No errors detected in %u functions." % num_funcs
+    print ("No errors detected in %u functions." % num_funcs)
 else:
     if num_errors > 1:
         err="errors"
     else:
         err="error"
-    print "%u %s detected in %u functions." % (num_errors, err, num_funcs)
+    print ("%u %s detected in %u functions." % (num_errors, err, num_funcs))
     sys.exit(1)


-- 
Meelis Roos (mroos@linux.ee)

                 reply	other threads:[~2014-06-06 11:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.SOC.1.00.1406061434000.8408@math.ut.ee \
    --to=mroos@linux.ee \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox