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