Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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'
  • Loading branch information
spaceone committed Jan 24, 2019
1 parent 7fea2d0 commit 3c7c56e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion circuits/core/values.py
Expand Up @@ -74,7 +74,7 @@ def __repr__(self):
def __str__(self):
"x.__str__() <==> str(x)"
if PY2:
return self.value.encode('utf-8')
return unicode(self.value).encode('utf-8')
return str(self.value)

def inform(self, force=False):
Expand Down

0 comments on commit 3c7c56e

Please sign in to comment.