mirror of
https://github.com/django/django.git
synced 2025-09-18 08:20:10 +00:00
Fixed #19543 -- implemented SimpleLazyObject.__repr__
Thanks to Florian Hahn for the patch
This commit is contained in:
parent
c8e3a23d0f
commit
0ea5bf88dd
3 changed files with 24 additions and 4 deletions
|
@ -305,6 +305,15 @@ class SimpleLazyObject(LazyObject):
|
|||
def __reduce__(self):
|
||||
return (self.__newobj__, (self.__class__,), self.__getstate__())
|
||||
|
||||
# Return a meaningful representation of the lazy object for debugging
|
||||
# without evaluating the wrapped object.
|
||||
def __repr__(self):
|
||||
if self._wrapped is empty:
|
||||
repr_attr = self._setupfunc
|
||||
else:
|
||||
repr_attr = self._wrapped
|
||||
return '<SimpleLazyObject: %r>' % repr_attr
|
||||
|
||||
# Need to pretend to be the wrapped class, for the sake of objects that care
|
||||
# about this (especially in equality tests)
|
||||
__class__ = property(new_method_proxy(operator.attrgetter("__class__")))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue