Commit 69139ead authored by Stefan Behnel's avatar Stefan Behnel

adapt some more syntax to Py2/Py3

parent 4487fad9
......@@ -167,7 +167,7 @@ class CheckAnalysers(type):
def call(*args, **kwargs):
retval = func(*args, **kwargs)
if retval is None:
print name, args, kwargs
print('%s %s %s' % (name, args, kwargs))
return retval
return call
......
......@@ -15,7 +15,7 @@ from . import Naming
#
def dumptree(t):
# For quick debugging in pipelines
print t.dump()
print(t.dump())
return t
def abort_on_errors(node):
......@@ -321,12 +321,12 @@ def run_pipeline(pipeline, source, printtree=True):
if phase is not None:
if DebugFlags.debug_verbose_pipeline:
t = time()
print "Entering pipeline phase %r" % phase
print("Entering pipeline phase %r" % phase)
if not printtree and isinstance(phase, PrintTree):
continue
data = phase(data)
if DebugFlags.debug_verbose_pipeline:
print " %.3f seconds" % (time() - t)
print(" %.3f seconds" % (time() - t))
except CompileError as err:
# err is set
Errors.report_error(err)
......
......@@ -22,7 +22,7 @@ import cython
cython.declare(_PRINTABLE=tuple)
if sys.version_info >= 3:
if sys.version_info[0] >= 3:
_PRINTABLE = (bytes, str, int, float)
else:
_PRINTABLE = (str, unicode, long, int, float)
......@@ -57,9 +57,9 @@ class TreeVisitor(object):
>>> tree = SampleNode(0, SampleNode(1), [SampleNode(2), SampleNode(3)])
>>> class MyVisitor(TreeVisitor):
... def visit_SampleNode(self, node):
... print "in", node.value, self.access_path
... print("in %s %s" % (node.value, self.access_path)
... self.visitchildren(node)
... print "out", node.value
... print("out %s" % node.value)
...
>>> MyVisitor().visit(tree)
in 0 []
......@@ -162,11 +162,11 @@ class TreeVisitor(object):
handler_method = getattr(self, pattern % mro_cls.__name__, None)
if handler_method is not None:
return handler_method
print type(self), cls
print('%s: %s' % (type(self), cls))
if self.access_path:
print self.access_path
print self.access_path[-1][0].pos
print self.access_path[-1][0].__dict__
print(self.access_path)
print(self.access_path[-1][0].pos)
print(self.access_path[-1][0].__dict__)
raise RuntimeError("Visitor %r does not accept object: %s" % (self, obj))
def visit(self, obj):
......
......@@ -240,7 +240,7 @@ class StructType(CythonType):
for key, value in cast_from.__dict__.items():
setattr(self, key, value)
else:
for key, value in data.iteritems():
for key, value in data.items():
setattr(self, key, value)
def __setattr__(self, key, value):
......@@ -267,7 +267,7 @@ class UnionType(CythonType):
datadict = data
if len(datadict) > 1:
raise AttributeError("Union can only store one field at a time.")
for key, value in datadict.iteritems():
for key, value in datadict.items():
setattr(self, key, value)
def __setattr__(self, key, value):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment