summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorPreston Holmes <preston@ptone.com>2013-03-06 16:00:05 -0800
committerPreston Holmes <preston@ptone.com>2013-03-06 16:13:12 -0800
commit0ea5bf88dddd7fbdef7fe8d00162c9753565f5c0 (patch)
tree18c72b0c276cbbd2f19b0911da113b3c91222d46 /django/utils
parentc8e3a23d0f6d6683c7d5d4f4107b0c716b879cf0 (diff)
Fixed #19543 -- implemented SimpleLazyObject.__repr__
Thanks to Florian Hahn for the patch
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/functional.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 69a32b101a..3e58674501 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -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__")))