Skip to content
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

Fix python2 str(circuits.core.values.Value()) #266

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@spaceone
Copy link
Contributor

commented Jan 24, 2019

I am not sure why Value has a __str__ method at all. But it's broken on
python2. It assumes value is always a unicode-string, while coroutines
can return anything, even lists. This causes various crashes.

>>> str(circuits.core.values.Value())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fbest/git/circuits/circuits/six.py", line 854, in <lambda>
    klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
  File "/home/fbest/git/circuits/circuits/core/values.py", line 78, in __str__
    return self.value.encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'
Fix python2 str(circuits.core.values.Value())
I am not sure why Value has a __str__ method at all. But it's broken on
python2. It assumes value is always a unicode-string, while coroutines
can return anything, even lists. This causes various crashes.

>>> str(circuits.core.values.Value())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fbest/git/circuits/circuits/six.py", line 854, in <lambda>
    klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
  File "/home/fbest/git/circuits/circuits/core/values.py", line 78, in __str__
    return self.value.encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'
@prologic

This comment has been minimized.

Copy link
Member

commented Jan 24, 2019

It exists mostly for debugability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.