소스 검색

[utils] Fix incompatibility of bisect[-skip-count] with Python 3

Summary:
This change replaces the print statements with print function calls
and also replaces the '/' operator (which is integer division in Py2,
but becomes floating point division in Py3) with the '//' operator
which has the same semantics in Py2 and Py3.

Reviewers: greened, michaelplatings, gottesmm

Reviewed By: greened

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68138

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373759 91177308-0d34-0410-b5e6-96231b3b80d8
Mikhail Maltsev 5 년 전
부모
커밋
fe080914cc
2개의 변경된 파일8개의 추가작업 그리고 6개의 파일을 삭제
  1. 3 2
      utils/bisect
  2. 5 4
      utils/bisect-skip-count

+ 3 - 2
utils/bisect

@@ -12,6 +12,7 @@
 # And bisect will continually call ./script.sh with various counts using
 # And bisect will continually call ./script.sh with various counts using
 # the exit status to determine success and failure.
 # the exit status to determine success and failure.
 #
 #
+from __future__ import print_function
 import os
 import os
 import sys
 import sys
 import argparse
 import argparse
@@ -34,10 +35,10 @@ print("End: %d" % end)
 
 
 last = None
 last = None
 while start != end and start != end-1:
 while start != end and start != end-1:
-    count = start + (end - start)/2
+    count = start + (end - start)//2
     print("Visiting Count: %d with (Start, End) = (%d,%d)" % (count, start, end))
     print("Visiting Count: %d with (Start, End) = (%d,%d)" % (count, start, end))
     cmd = [x % {'count':count} for x in args.command]
     cmd = [x % {'count':count} for x in args.command]
-    print cmd
+    print(cmd)
     result = subprocess.call(cmd)
     result = subprocess.call(cmd)
     if result == 0:
     if result == 0:
         print("    PASSES! Setting start to count")
         print("    PASSES! Setting start to count")

+ 5 - 4
utils/bisect-skip-count

@@ -20,6 +20,7 @@
 # result.  Incrementing the last good count by one or decrementing the
 # result.  Incrementing the last good count by one or decrementing the
 # last good skip by one should produce a failure.
 # last good skip by one should produce a failure.
 #
 #
+from __future__ import print_function
 import os
 import os
 import sys
 import sys
 import argparse
 import argparse
@@ -52,10 +53,10 @@ print("End: %d" % end)
 
 
 last = None
 last = None
 while start != end and start != end-1:
 while start != end and start != end-1:
-    count = start + (end - start)/2
+    count = start + (end - start)//2
     print("Visiting Skip: %d with (Start, End) = (%d,%d)" % (count, start, end))
     print("Visiting Skip: %d with (Start, End) = (%d,%d)" % (count, start, end))
     cmd = [x % {'skip':count, 'count':-1} for x in args.command]
     cmd = [x % {'skip':count, 'count':-1} for x in args.command]
-    print cmd
+    print(cmd)
     try:
     try:
         result = subprocess.call(cmd, shell=args.shell, timeout=args.timeout)
         result = subprocess.call(cmd, shell=args.shell, timeout=args.timeout)
         if result == 0:
         if result == 0:
@@ -75,10 +76,10 @@ print("Bisect of Count starting!")
 print("Start: %d" % start)
 print("Start: %d" % start)
 print("End: %d" % end)
 print("End: %d" % end)
 while start != end and start != end-1:
 while start != end and start != end-1:
-    count = start + (end - start)/2
+    count = start + (end - start)//2
     print("Visiting Count: %d with (Start, End) = (%d,%d)" % (count, start, end))
     print("Visiting Count: %d with (Start, End) = (%d,%d)" % (count, start, end))
     cmd = [x % {'count':count, 'skip':firstcount } for x in args.command]
     cmd = [x % {'count':count, 'skip':firstcount } for x in args.command]
-    print cmd
+    print(cmd)
     try:
     try:
         result = subprocess.call(cmd, shell=args.shell, timeout=args.timeout)
         result = subprocess.call(cmd, shell=args.shell, timeout=args.timeout)
         if result == 0:
         if result == 0: