diff options
author | Collin Winter <collinw@gmail.com> | 2007-07-17 20:59:35 (GMT) |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2007-07-17 20:59:35 (GMT) |
commit | 6f2df4d5e193d54244b0c2de91ef0ab1604b9243 (patch) | |
tree | 5e172400da7561eb4bb8fafc62c8cab511d74dad /Demo/parser | |
parent | a8c360ee76fb76902a2e2140fbb38d4b06b2d9fb (diff) | |
download | cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.zip cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.tar.gz cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.tar.bz2 |
Run 2to3 over the Demo/ directory to shut up parse errors from 2to3 about lingering print statements.
Diffstat (limited to 'Demo/parser')
-rw-r--r-- | Demo/parser/example.py | 6 | ||||
-rwxr-xr-x | Demo/parser/test_parser.py | 14 | ||||
-rw-r--r-- | Demo/parser/unparse.py | 17 |
3 files changed, 19 insertions, 18 deletions
diff --git a/Demo/parser/example.py b/Demo/parser/example.py index 2aa9ec2..c2f0883 100644 --- a/Demo/parser/example.py +++ b/Demo/parser/example.py @@ -63,7 +63,7 @@ class SuiteInfoBase: return self._name def get_class_names(self): - return self._class_info.keys() + return list(self._class_info.keys()) def get_class_info(self, name): return self._class_info[name] @@ -79,7 +79,7 @@ class SuiteFuncInfo: # Mixin class providing access to function names and info. def get_function_names(self): - return self._function_info.keys() + return list(self._function_info.keys()) def get_function_info(self, name): return self._function_info[name] @@ -97,7 +97,7 @@ class ClassInfo(SuiteInfoBase): SuiteInfoBase.__init__(self, tree and tree[-1] or None) def get_method_names(self): - return self._function_info.keys() + return list(self._function_info.keys()) def get_method_info(self, name): return self._function_info[name] diff --git a/Demo/parser/test_parser.py b/Demo/parser/test_parser.py index 1589f3b..e4d5571 100755 --- a/Demo/parser/test_parser.py +++ b/Demo/parser/test_parser.py @@ -9,7 +9,7 @@ _numFailed = 0 def testChunk(t, fileName): global _numFailed - print '----', fileName, + print('----', fileName, end=' ') try: ast = parser.suite(t) tup = parser.ast2tuple(ast) @@ -18,17 +18,17 @@ def testChunk(t, fileName): ast = None new = parser.tuple2ast(tup) except parser.ParserError as err: - print - print 'parser module raised exception on input file', fileName + ':' + print() + print('parser module raised exception on input file', fileName + ':') traceback.print_exc() _numFailed = _numFailed + 1 else: if tup != parser.ast2tuple(new): - print - print 'parser module failed on input file', fileName + print() + print('parser module failed on input file', fileName) _numFailed = _numFailed + 1 else: - print 'o.k.' + print('o.k.') def testFile(fileName): t = open(fileName).read() @@ -41,7 +41,7 @@ def test(): import glob args = glob.glob("*.py") args.sort() - map(testFile, args) + list(map(testFile, args)) sys.exit(_numFailed != 0) if __name__ == '__main__': diff --git a/Demo/parser/unparse.py b/Demo/parser/unparse.py index 751ea6f..6582487 100644 --- a/Demo/parser/unparse.py +++ b/Demo/parser/unparse.py @@ -1,7 +1,7 @@ "Usage: unparse.py <path to source file>" import sys import _ast -import cStringIO +import io import os def interleave(inter, f, seq): @@ -9,7 +9,7 @@ def interleave(inter, f, seq): """ seq = iter(seq) try: - f(seq.next()) + f(next(seq)) except StopIteration: pass else: @@ -28,7 +28,7 @@ class Unparser: self.f = file self._indent = 0 self.dispatch(tree) - print >>self.f,"" + print("", file=self.f) self.f.flush() def fill(self, text = ""): @@ -326,7 +326,8 @@ class Unparser: def _Dict(self, t): self.write("{") - def writem((k, v)): + def writem(xxx_todo_changeme): + (k, v) = xxx_todo_changeme self.dispatch(k) self.write(": ") self.dispatch(v) @@ -482,17 +483,17 @@ def testdir(a): try: names = [n for n in os.listdir(a) if n.endswith('.py')] except OSError: - print >> sys.stderr, "Directory not readable: %s" % a + print("Directory not readable: %s" % a, file=sys.stderr) else: for n in names: fullname = os.path.join(a, n) if os.path.isfile(fullname): - output = cStringIO.StringIO() - print 'Testing %s' % fullname + output = io.StringIO() + print('Testing %s' % fullname) try: roundtrip(fullname, output) except Exception as e: - print ' Failed to compile, exception is %s' % repr(e) + print(' Failed to compile, exception is %s' % repr(e)) elif os.path.isdir(fullname): testdir(fullname) |