diff options
author | Dan Liew <daniel.liew@imperial.ac.uk> | 2013-08-13 12:27:33 +0100 |
---|---|---|
committer | Dan Liew <daniel.liew@imperial.ac.uk> | 2013-08-13 12:27:33 +0100 |
commit | e211c407bcf1631c448800cb49044b2f48bee638 (patch) | |
tree | 4f25ff5c653978c45b0f292ae27c953d0b8659aa /tools/ktest-tool | |
parent | 73c6172015c6ef51ba438fb501392c7c29f4188e (diff) | |
download | klee-e211c407bcf1631c448800cb49044b2f48bee638.tar.gz |
Modified ktest-tool so that it is compatible with python3.
Diffstat (limited to 'tools/ktest-tool')
-rwxr-xr-x | tools/ktest-tool/ktest-tool | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/ktest-tool/ktest-tool b/tools/ktest-tool/ktest-tool index a19e09a5..b7504be8 100755 --- a/tools/ktest-tool/ktest-tool +++ b/tools/ktest-tool/ktest-tool @@ -13,21 +13,21 @@ class KTest: @staticmethod def fromfile(path): if not os.path.exists(path): - print "ERROR: file %s not found" % (path) + print("ERROR: file %s not found" % (path)) sys.exit(1) f = open(path,'rb') hdr = f.read(5) - if len(hdr)!=5 or (hdr!='KTEST' and hdr != "BOUT\n"): - raise KTestError,'unrecognized file' + if len(hdr)!=5 or (hdr!=b'KTEST' and hdr != b"BOUT\n"): + raise KTestError('unrecognized file') version, = struct.unpack('>i', f.read(4)) if version > version_no: - raise KTestError,'unrecognized version' + raise KTestError('unrecognized version') numArgs, = struct.unpack('>i', f.read(4)) args = [] for i in range(numArgs): size, = struct.unpack('>i', f.read(4)) - args.append(f.read(size)) + args.append(str(f.read(size).decode(encoding='ascii'))) if version >= 2: symArgvs, = struct.unpack('>i', f.read(4)) @@ -90,23 +90,23 @@ def main(args): for file in args: b = KTest.fromfile(file) pos = 0 - print 'ktest file : %r' % file - print 'args : %r' % b.args - print 'num objects: %r' % len(b.objects) + print('ktest file : %r' % file) + print('args : %r' % b.args) + print('num objects: %r' % len(b.objects)) for i,(name,data) in enumerate(b.objects): if opts.trimZeros: str = trimZeros(data) else: str = data - print 'object %4d: name: %r' % (i, name) - print 'object %4d: size: %r' % (i, len(data)) + print('object %4d: name: %r' % (i, name)) + print('object %4d: size: %r' % (i, len(data))) if opts.writeInts and len(data) == 4: - print 'object %4d: data: %r' % (i, struct.unpack('i',str)[0]) + print('object %4d: data: %r' % (i, struct.unpack('i',str)[0])) else: - print 'object %4d: data: %r' % (i, str) + print('object %4d: data: %r' % (i, str)) if file != args[-1]: - print + print() if __name__=='__main__': main(sys.argv) |