summaryrefslogtreecommitdiffstats
path: root/Lib/compiler
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-02-09 05:37:30 (GMT)
committerGuido van Rossum <guido@python.org>2007-02-09 05:37:30 (GMT)
commitbe19ed77ddb047e02fe94d142181062af6d99dcc (patch)
tree70f214e06554046fcccbadeb78665f25e07ce965 /Lib/compiler
parent452bf519a70c3db0e7f0d2540b1bfb07d9085583 (diff)
downloadcpython-be19ed77ddb047e02fe94d142181062af6d99dcc.zip
cpython-be19ed77ddb047e02fe94d142181062af6d99dcc.tar.gz
cpython-be19ed77ddb047e02fe94d142181062af6d99dcc.tar.bz2
Fix most trivially-findable print statements.
There's one major and one minor category still unfixed: doctests are the major category (and I hope to be able to augment the refactoring tool to refactor bona fide doctests soon); other code generating print statements in strings is the minor category. (Oh, and I don't know if the compiler package works.)
Diffstat (limited to 'Lib/compiler')
-rw-r--r--Lib/compiler/future.py6
-rw-r--r--Lib/compiler/pyassem.py24
-rw-r--r--Lib/compiler/pycodegen.py10
-rw-r--r--Lib/compiler/symbols.py30
-rw-r--r--Lib/compiler/syntax.py2
-rw-r--r--Lib/compiler/transformer.py2
-rw-r--r--Lib/compiler/visitor.py16
7 files changed, 45 insertions, 45 deletions
diff --git a/Lib/compiler/future.py b/Lib/compiler/future.py
index fef189e..6e72490 100644
--- a/Lib/compiler/future.py
+++ b/Lib/compiler/future.py
@@ -65,9 +65,9 @@ if __name__ == "__main__":
from compiler import parseFile, walk
for file in sys.argv[1:]:
- print file
+ print(file)
tree = parseFile(file)
v = FutureParser()
walk(tree, v)
- print v.found
- print
+ print(v.found)
+ print()
diff --git a/Lib/compiler/pyassem.py b/Lib/compiler/pyassem.py
index 86e2c49..9f45d61 100644
--- a/Lib/compiler/pyassem.py
+++ b/Lib/compiler/pyassem.py
@@ -19,10 +19,10 @@ class FlowGraph:
def startBlock(self, block):
if self._debug:
if self.current:
- print "end", repr(self.current)
- print " next", self.current.next
- print " ", self.current.get_children()
- print repr(block)
+ print("end", repr(self.current))
+ print(" next", self.current.next)
+ print(" ", self.current.get_children())
+ print(repr(block))
self.current = block
def nextBlock(self, block=None):
@@ -68,7 +68,7 @@ class FlowGraph:
def emit(self, *inst):
if self._debug:
- print "\t", inst
+ print("\t", inst)
if inst[0] in ['RETURN_VALUE', 'YIELD_VALUE']:
self.current.addOutEdge(self.exit)
if len(inst) == 2 and isinstance(inst[1], Block):
@@ -400,12 +400,12 @@ class PyFlowGraph(FlowGraph):
for t in self.insts:
opname = t[0]
if opname == "SET_LINENO":
- print
+ print()
if len(t) == 1:
- print "\t", "%3d" % pc, opname
+ print("\t", "%3d" % pc, opname)
pc = pc + 1
else:
- print "\t", "%3d" % pc, opname, t[1]
+ print("\t", "%3d" % pc, opname, t[1])
pc = pc + 3
if io:
sys.stdout = save
@@ -601,8 +601,8 @@ class PyFlowGraph(FlowGraph):
try:
lnotab.addCode(self.opnum[opname], lo, hi)
except ValueError:
- print opname, oparg
- print self.opnum[opname], lo, hi
+ print(opname, oparg)
+ print(self.opnum[opname], lo, hi)
raise
self.stage = DONE
@@ -744,7 +744,7 @@ class StackDepthTracker:
for i in insts:
opname = i[0]
if debug:
- print i,
+ print(i, end=' ')
delta = self.effect.get(opname, None)
if delta is not None:
depth = depth + delta
@@ -763,7 +763,7 @@ class StackDepthTracker:
if depth > maxDepth:
maxDepth = depth
if debug:
- print depth, maxDepth
+ print(depth, maxDepth)
return maxDepth
effect = {
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
index a1dc971..0e49781 100644
--- a/Lib/compiler/pycodegen.py
+++ b/Lib/compiler/pycodegen.py
@@ -112,7 +112,7 @@ class Module(AbstractCompileMode):
gen = ModuleCodeGenerator(tree)
if display:
import pprint
- print pprint.pprint(tree)
+ print(pprint.pprint(tree))
self.code = gen.getCode()
def dump(self, f):
@@ -1018,7 +1018,7 @@ class CodeGenerator:
self.set_lineno(node)
self.delName(node.name)
else:
- print "oops", node.flags
+ print("oops", node.flags)
def visitAssAttr(self, node):
self.visit(node.expr)
@@ -1027,8 +1027,8 @@ class CodeGenerator:
elif node.flags == 'OP_DELETE':
self.emit('DELETE_ATTR', self.mangle(node.attrname))
else:
- print "warning: unexpected flags:", node.flags
- print node
+ print("warning: unexpected flags:", node.flags)
+ print(node)
def _visitAssSequence(self, node, op='UNPACK_SEQUENCE'):
if findOp(node) != 'OP_DELETE':
@@ -1189,7 +1189,7 @@ class CodeGenerator:
elif node.flags == 'OP_DELETE':
self.emit('DELETE_SLICE+%d' % slice)
else:
- print "weird slice", node.flags
+ print("weird slice", node.flags)
raise
def visitSubscript(self, node, aug_flag=None):
diff --git a/Lib/compiler/symbols.py b/Lib/compiler/symbols.py
index 3585efc..6c19b5b 100644
--- a/Lib/compiler/symbols.py
+++ b/Lib/compiler/symbols.py
@@ -76,12 +76,12 @@ class Scope:
return self.children
def DEBUG(self):
- print >> sys.stderr, self.name, self.nested and "nested" or ""
- print >> sys.stderr, "\tglobals: ", self.globals
- print >> sys.stderr, "\tcells: ", self.cells
- print >> sys.stderr, "\tdefs: ", self.defs
- print >> sys.stderr, "\tuses: ", self.uses
- print >> sys.stderr, "\tfrees:", self.frees
+ print(self.name, self.nested and "nested" or "", file=sys.stderr)
+ print("\tglobals: ", self.globals, file=sys.stderr)
+ print("\tcells: ", self.cells, file=sys.stderr)
+ print("\tdefs: ", self.defs, file=sys.stderr)
+ print("\tuses: ", self.uses, file=sys.stderr)
+ print("\tfrees:", self.frees, file=sys.stderr)
def check_name(self, name):
"""Return scope of name.
@@ -429,7 +429,7 @@ if __name__ == "__main__":
if not (s.startswith('_[') or s.startswith('.'))]
for file in sys.argv[1:]:
- print file
+ print(file)
f = open(file)
buf = f.read()
f.close()
@@ -443,10 +443,10 @@ if __name__ == "__main__":
names2 = s.scopes[tree].get_names()
if not list_eq(mod_names, names2):
- print
- print "oops", file
- print sorted(mod_names)
- print sorted(names2)
+ print()
+ print("oops", file)
+ print(sorted(mod_names))
+ print(sorted(names2))
sys.exit(-1)
d = {}
@@ -460,11 +460,11 @@ if __name__ == "__main__":
l = [sc for sc in scopes
if sc.name == s.get_name()]
if len(l) > 1:
- print "skipping", s.get_name()
+ print("skipping", s.get_name())
else:
if not list_eq(get_names(s.get_namespace()),
l[0].get_names()):
- print s.get_name()
- print sorted(get_names(s.get_namespace()))
- print sorted(l[0].get_names())
+ print(s.get_name())
+ print(sorted(get_names(s.get_namespace())))
+ print(sorted(l[0].get_names()))
sys.exit(-1)
diff --git a/Lib/compiler/syntax.py b/Lib/compiler/syntax.py
index a45d9c2..6187b47 100644
--- a/Lib/compiler/syntax.py
+++ b/Lib/compiler/syntax.py
@@ -32,7 +32,7 @@ class SyntaxErrorChecker:
def error(self, node, msg):
self.errors = self.errors + 1
if self.multi is not None:
- print "%s:%s: %s" % (node.filename, node.lineno, msg)
+ print("%s:%s: %s" % (node.filename, node.lineno, msg))
else:
raise SyntaxError, "%s (%s:%s)" % (msg, node.filename, node.lineno)
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index 0d00340..3a2be13 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -86,7 +86,7 @@ def Node(*args):
try:
return nodes[kind](*args[1:])
except TypeError:
- print nodes[kind], len(args), args
+ print(nodes[kind], len(args), args)
raise
else:
raise WalkerError, "Can't find appropriate Node type: %s" % str(args)
diff --git a/Lib/compiler/visitor.py b/Lib/compiler/visitor.py
index f10f560..99c6716 100644
--- a/Lib/compiler/visitor.py
+++ b/Lib/compiler/visitor.py
@@ -79,20 +79,20 @@ class ExampleASTVisitor(ASTVisitor):
meth = getattr(self.visitor, 'visit' + className, 0)
self._cache[node.__class__] = meth
if self.VERBOSE > 1:
- print "dispatch", className, (meth and meth.__name__ or '')
+ print("dispatch", className, (meth and meth.__name__ or ''))
if meth:
meth(node, *args)
elif self.VERBOSE > 0:
klass = node.__class__
if klass not in self.examples:
self.examples[klass] = klass
- print
- print self.visitor
- print klass
+ print()
+ print(self.visitor)
+ print(klass)
for attr in dir(node):
if attr[0] != '_':
- print "\t", "%-12.12s" % attr, getattr(node, attr)
- print
+ print("\t", "%-12.12s" % attr, getattr(node, attr))
+ print()
return self.default(node, *args)
# XXX this is an API change
@@ -107,7 +107,7 @@ def walk(tree, visitor, walker=None, verbose=None):
return walker.visitor
def dumpNode(node):
- print node.__class__
+ print(node.__class__)
for attr in dir(node):
if attr[0] != '_':
- print "\t", "%-10.10s" % attr, getattr(node, attr)
+ print("\t", "%-10.10s" % attr, getattr(node, attr))