diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index a08ce2710d..faf3bbe5c8 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -7,7 +7,6 @@ from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation, getcontex from functools import wraps from inspect import unwrap from operator import itemgetter -from pprint import pformat from urllib.parse import quote from django.utils import formats @@ -967,12 +966,3 @@ def pluralize(value, arg="s"): def phone2numeric_filter(value): """Take a phone number and converts it in to its numerical equivalent.""" return phone2numeric(value) - - -@register.filter(is_safe=True) -def pprint(value): - """A wrapper around pprint.pprint -- for debugging, really.""" - try: - return pformat(value) - except Exception as e: - return "Error in formatting: %s: %s" % (e.__class__.__name__, e) diff --git a/django/utils/repr.py b/django/utils/repr.py index 510a7d990b..567b70903b 100644 --- a/django/utils/repr.py +++ b/django/utils/repr.py @@ -12,9 +12,7 @@ class DjangoRepr(reprlib.Repr): setattr(self, attr, limit) def repr_str(self, x, level): - if len(x) > self.maxstring: - return x[: self.maxstring] + self.gen_trim_msg(len(x)) - return x[: self.maxstring] + return "'%s'" % (x[: self.maxstring] + self.gen_trim_msg(len(x))) def repr_instance(self, x, level): s = builtins.repr(x) diff --git a/django/views/debug.py b/django/views/debug.py index f533a93657..f77c96d44d 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -358,13 +358,13 @@ class ExceptionReporter: if "vars" in frame: frame_vars = [] for k, v in frame["vars"]: + try: if isinstance(v, Sized) and len(v) > self.PRINT_LIMIT: diff = len(v) - self.PRINT_LIMIT self.repr_instance.fillvalue = ( "..." % diff ) - v = self.repr_instance.repr(v) except Exception as e: