diff options
author | Fred Wright <fw@fwright.net> | 2016-04-12 15:34:41 -0700 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2016-04-14 03:48:48 -0400 |
commit | 25c15e4a9d3b59e01771709fe4dfaf23bb2dc1bb (patch) | |
tree | de270f273e82978bfe16be1b9d9bb8a3a55fbdb5 /devtools/regressdiff | |
parent | ad651478146f2b219b7294ee67c144fa7e78cb26 (diff) | |
download | gpsd-25c15e4a9d3b59e01771709fe4dfaf23bb2dc1bb.tar.gz |
Fixes more devtools programs for Python 3.
This fixes the aivdmtable, regressdiff, sizes, and striplog programs
to work with Python 3. The "striplog" program didn't require any
actual changes, but it still adds the usual compatibility comment and
future import.
In the case of "sizes", it also adjusts the scons cleanup pattern to
include the temporary directory, and adds explicit checking (with an
exception) for build failures.
TESTED:
Ran all four programs with both Python 2 and Python 3.
Diffstat (limited to 'devtools/regressdiff')
-rwxr-xr-x | devtools/regressdiff | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/devtools/regressdiff b/devtools/regressdiff index 947fa8aa..fa658c12 100755 --- a/devtools/regressdiff +++ b/devtools/regressdiff @@ -5,12 +5,16 @@ # # This file is Copyright (c) 2010 by the GPSD project # BSD terms apply: see the file COPYING in the distribution root for details. +# +# This code runs compatibly under Python 2 and 3.x for x >= 2. +# Preserve this property! +from __future__ import absolute_import, print_function, division import sys -class BufferedFile(file): +class BufferedFile(object): def __init__(self, name): - file.__init__(self, name) + self.file = open(name) self.linebuffer = [] self.lineno = 0 def readline(self): @@ -18,7 +22,7 @@ class BufferedFile(file): if self.linebuffer: return self.linebuffer.pop() else: - return file.readline(self) + return self.file.readline() def pushback(self, line): self.lineno -= 1 self.linebuffer.append(line) @@ -42,6 +46,6 @@ if __name__ == "__main__": f2 = BufferedFile(sys.argv[2]) eaten = eatspan(f1, f2) - print "First %d lines match" % eaten - print `f1.peek()` - print `f2.peek()` + print("First %d lines match" % eaten) + print(f1.peek()) + print(f2.peek()) |