Fixed #25000 -- Fixed cast to string for lazy objects.

Implemented __str__() to return the string-representation of the
proxied object, not the proxy itself, if the lazy object didn't have
a string-like object in its resultclasses.
This commit is contained in:
Marten Kenbeek 2015-06-20 14:00:55 +02:00 committed by Tim Graham
parent c45fbd060a
commit 290ff35e6c
2 changed files with 29 additions and 0 deletions

View file

@ -128,6 +128,11 @@ def lazy(func, *resultclasses):
else:
return func(*self.__args, **self.__kw)
def __str__(self):
# object defines __str__(), so __prepare_class__() won't overload
# a __str__() method from the proxied class.
return str(self.__cast())
def __ne__(self, other):
if isinstance(other, Promise):
other = other.__cast()