mirror of
https://github.com/python/cpython.git
synced 2025-10-16 19:57:59 +00:00
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.)
This commit is contained in:
parent
452bf519a7
commit
be19ed77dd
331 changed files with 2567 additions and 2648 deletions
|
@ -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()
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue