Skip to content

from __future__ import unicode_literals breaks fysom #31

@sjlongland

Description

@sjlongland

The unicode_literals feature 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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions