Skip to content
Browse files

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/", line 854, in <lambda>
    klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
  File "/home/fbest/git/circuits/circuits/core/", 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 3c7c56e10455f1506ac57b9c9911e55e85d56282
Showing with 1 addition and 1 deletion.
  1. +1 −1 circuits/core/
@@ -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):

0 comments on commit 3c7c56e

Please sign in to comment.
You can’t perform that action at this time.