1
0
mirror of https://github.com/django/django.git synced 2025-06-10 14:09:14 +00:00

fix: auth tests - quote all strings in repr implementation

This commit is contained in:
Keerthi Vasan 2024-02-03 18:21:13 +05:30
parent 3248acee53
commit 0f59f75254
3 changed files with 2 additions and 14 deletions

View File

@ -7,7 +7,6 @@ from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation, getcontex
from functools import wraps from functools import wraps
from inspect import unwrap from inspect import unwrap
from operator import itemgetter from operator import itemgetter
from pprint import pformat
from urllib.parse import quote from urllib.parse import quote
from django.utils import formats from django.utils import formats
@ -967,12 +966,3 @@ def pluralize(value, arg="s"):
def phone2numeric_filter(value): def phone2numeric_filter(value):
"""Take a phone number and converts it in to its numerical equivalent.""" """Take a phone number and converts it in to its numerical equivalent."""
return phone2numeric(value) 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)

View File

@ -12,9 +12,7 @@ class DjangoRepr(reprlib.Repr):
setattr(self, attr, limit) setattr(self, attr, limit)
def repr_str(self, x, level): def repr_str(self, x, level):
if len(x) > self.maxstring: return "'%s'" % (x[: self.maxstring] + self.gen_trim_msg(len(x)))
return x[: self.maxstring] + self.gen_trim_msg(len(x))
return x[: self.maxstring]
def repr_instance(self, x, level): def repr_instance(self, x, level):
s = builtins.repr(x) s = builtins.repr(x)

View File

@ -358,13 +358,13 @@ class ExceptionReporter:
if "vars" in frame: if "vars" in frame:
frame_vars = [] frame_vars = []
for k, v in frame["vars"]: for k, v in frame["vars"]:
try: try:
if isinstance(v, Sized) and len(v) > self.PRINT_LIMIT: if isinstance(v, Sized) and len(v) > self.PRINT_LIMIT:
diff = len(v) - self.PRINT_LIMIT diff = len(v) - self.PRINT_LIMIT
self.repr_instance.fillvalue = ( self.repr_instance.fillvalue = (
"...<trimmed %d bytes string>" % diff "...<trimmed %d bytes string>" % diff
) )
v = self.repr_instance.repr(v) v = self.repr_instance.repr(v)
except Exception as e: except Exception as e: