forked from oxplot/fysom
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from __future__ import unicode_literals
breaks fysom
#31
Comments
Oh shoot, thanks for reporting. In 2.x afaik unicode objects are not strings, but this should be easy enough to fix. Will have a look as soon as I am able, but I reckon a `str()` wrap will do it
… On 13 Mar 2017, at 04:55, Stuart Longland ***@***.***> wrote:
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 ***@***.*** /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 ***@***.*** /tmp/fysom $ python3 test.py
RC=0 ***@***.*** /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
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
sjlongland
pushed a commit
to vrtsystems/fysom
that referenced
this issue
Mar 14, 2017
Python 3 is happy to receive `__name__` objects as Unicode or plain strings, but Python 2 is not. This bug shows itself when `unicode_literals` is imported from calling code. mriehl#31
I've just quickly thrown together a pull request with a possible fix. I'll see if I can put a quick test case in. |
Cool thanks. I'll try to make room for a release tomorrow |
On 15/03/17 03:44, Maximilien Riehl wrote:
Cool thanks. I'll try to make room for a release tomorrow
No problems, many thanks. :-)
…--
Stuart Longland (aka Redhatter, VK4MSL)
I haven't lost my mind...
...it's backed up on a tape somewhere.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
:The text was updated successfully, but these errors were encountered: