RC=0 stuartl@rikishi /tmp/fysom $ cat test.py
from __future__ import unicode_literals
from fysom import Fysom
fysom = Fysom({
'initial': 'green',
'events': [
{'name': 'warn', 'src': 'green', 'dst': 'yellow'},
{'name': 'panic', 'src': 'yellow', 'dst': 'red'},
{'name': 'calm', 'src': 'red', 'dst': 'yellow'},
{'name': 'clear', 'src': 'yellow', 'dst': 'green'},
{'name': 'warm', 'src': 'green', 'dst': 'blue'}
]
})
RC=0 stuartl@rikishi /tmp/fysom $ python3 test.py
RC=0 stuartl@rikishi /tmp/fysom $ python2 test.py
Traceback (most recent call last):
File "test.py", line 11, in <module>
{'name': 'warm', 'src': 'green', 'dst': 'blue'}
File "/usr/lib64/python2.7/site-packages/fysom/__init__.py", line 124, in __init__
self._apply(cfg)
File "/usr/lib64/python2.7/site-packages/fysom/__init__.py", line 195, in _apply
setattr(self, name, self._build_event(name))
File "/usr/lib64/python2.7/site-packages/fysom/__init__.py", line 261, in _build_event
fn.__name__ = event
TypeError: __name__ must be set to a string object
The
unicode_literalsfeature is a way to get Python 2.7 code to behave a little more like 3.x code by assuming that string literals are Unicode strings rather than byte strings.Unfortunately, it breaks
fysom: