mirror of
https://github.com/django/django.git
synced 2025-04-06 22:46:41 +00:00
refactor: move repr fill value generation to custom class
This commit is contained in:
parent
4182d06f7c
commit
cf43a55647
@ -3,7 +3,6 @@
|
||||
import random as random_module
|
||||
import re
|
||||
import types
|
||||
from collections.abc import Sized
|
||||
from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation, getcontext
|
||||
from functools import wraps
|
||||
from inspect import unwrap
|
||||
@ -978,9 +977,6 @@ def pprint(value):
|
||||
repr_instance = DebugRepr(limit=EXCEPTION_PRINT_LIMIT)
|
||||
|
||||
try:
|
||||
if isinstance(value, Sized) and len(value) > EXCEPTION_PRINT_LIMIT:
|
||||
diff = len(value) - EXCEPTION_PRINT_LIMIT
|
||||
repr_instance.fillvalue = "...<trimmed %d bytes string>" % diff
|
||||
value = repr_instance.repr(value)
|
||||
|
||||
except Exception as e:
|
||||
|
@ -4,6 +4,7 @@ import re
|
||||
import reprlib
|
||||
import secrets
|
||||
import unicodedata
|
||||
from collections.abc import Sized
|
||||
from gzip import GzipFile
|
||||
from gzip import compress as gzip_compress
|
||||
from io import BytesIO
|
||||
@ -502,6 +503,12 @@ class DebugRepr(reprlib.Repr):
|
||||
return s[: self.maxother] + self.gen_trim_msg(len(s))
|
||||
return s
|
||||
|
||||
def print(self, value):
|
||||
if isinstance(value, Sized) and len(value) > self.limit:
|
||||
length = len(value)
|
||||
self.fillvalue = self.gen_trim_msg(length)
|
||||
return self.repr(value)
|
||||
|
||||
def gen_trim_msg(self, length):
|
||||
if length <= self.limit:
|
||||
return ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user