-from __future__ import print_function
+from __future__ import absolute_import, print_function
from traceback import print_exception
import sys
if py3:
+ range = range
str_type = str
def add_ex_tb(ex):
"""Do nothing (already handled by Python 3 infrastructure)."""
return ex
+ def items(x):
+ return x.items()
+
else: # Python 2
+ range = xrange
str_type = basestring
def add_ex_tb(ex):
tb = getattr(ex, '__traceback__', None)
print_exception(type(ex), ex, tb)
+ def items(x):
+ return x.iteritems()
+
+
def wrap_main(main):
"""Run main() and raise a SystemExit with the return value if it
returns, pass along any SystemExit it raises, convert