Emulator not starting with Python 3.x
jcleung5549 opened this issue · 3 comments
Error message
except Exception,e:
^
SyntaxError: invalid syntax
The above is the Python 2.x syntax.
The 3.x syntax "except Exception as e:" also works with Python 2.6. Since the emulator's initial development was on 2.7, the resolution is just to use the 3.x syntax, instead of use the syntax in 'six' package.
Also needed to fix xrange() undefined. errors. xrange() was replaced with range() in Python 3. However, range() has difference meaning in Python 2.x.
python 2 | python 3
xrange(10) | range(10)
range(10) | list(range(10))
So changing the calls to range() may cause unexpected behavior when running on Python 2.x. If the usage was not in a for-loop, we could insert the code below. It seems more straightforward to limit execution to Python 3.x.
if sys.version_info < (3,):
range = xrange