Skip to content

Commit 3f2cb55

Browse files
ref: kill unused to_unicode and pprint template filter (#71062)
leftovers from python 2 <!-- Describe your PR here. -->
1 parent 5849309 commit 3f2cb55

File tree

3 files changed

+3
-39
lines changed

3 files changed

+3
-39
lines changed

src/sentry/interfaces/http.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
from django.utils.translation import gettext as _
66

77
from sentry.interfaces.base import Interface
8-
from sentry.utils import json
98
from sentry.utils.json import prune_empty_keys
109
from sentry.utils.safe import get_path, safe_urlencode
11-
from sentry.utils.strings import to_unicode
1210
from sentry.web.helpers import render_to_string
1311

1412

@@ -63,10 +61,6 @@ def fix_broken_encoding(value):
6361
return value
6462

6563

66-
def jsonify(value):
67-
return to_unicode(value) if isinstance(value, str) else json.dumps(value)
68-
69-
7064
class Http(Interface):
7165
"""
7266
The Request information is stored in the Http interface. Two arguments

src/sentry/templatetags/sentry_helpers.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
from django import template
1010
from django.template.defaultfilters import stringfilter
1111
from django.utils import timezone as django_timezone
12-
from django.utils.html import escape
13-
from django.utils.safestring import mark_safe
1412
from django.utils.translation import gettext as _
1513
from packaging.version import parse as parse_version
1614

1715
from sentry import options
1816
from sentry.api.serializers import serialize as serialize_func
1917
from sentry.utils import json
2018
from sentry.utils.strings import soft_break as _soft_break
21-
from sentry.utils.strings import soft_hyphenate, to_unicode, truncatechars
19+
from sentry.utils.strings import soft_hyphenate, truncatechars
2220

2321
SentryVersion = namedtuple("SentryVersion", ["current", "latest", "update_available", "build"])
2422

@@ -139,21 +137,6 @@ def security_contact():
139137
return options.get("system.security-email") or options.get("system.admin-email")
140138

141139

142-
@register.filter
143-
def pprint(value, break_after=10):
144-
"""
145-
break_after is used to define how often a <span> is
146-
inserted (for soft wrapping).
147-
"""
148-
149-
value = to_unicode(value)
150-
return mark_safe(
151-
"<span></span>".join(
152-
escape(value[i : (i + break_after)]) for i in range(0, len(value), break_after)
153-
)
154-
)
155-
156-
157140
@register.filter
158141
def is_url(value):
159142
if not isinstance(value, str):

src/sentry/utils/strings.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import string
88
import zlib
99
from collections.abc import Callable
10-
from typing import Any, overload
10+
from typing import overload
1111

12-
from django.utils.encoding import force_str, smart_str
12+
from django.utils.encoding import smart_str
1313

1414
_sprintf_placeholder_re = re.compile(
1515
r"%(?:\d+\$)?[+-]?(?:[ 0]|\'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX]"
@@ -116,19 +116,6 @@ def soft_break_delimiter(match: re.Match[str]) -> str:
116116
return re.sub(rf"\S{{{length},}}", soft_break_delimiter, value)
117117

118118

119-
def to_unicode(value: Any) -> str:
120-
try:
121-
value = str(force_str(value))
122-
except (UnicodeEncodeError, UnicodeDecodeError):
123-
value = "(Error decoding value)"
124-
except Exception: # in some cases we get a different exception
125-
try:
126-
value = str(repr(type(value)))
127-
except Exception:
128-
value = "(Error decoding value)"
129-
return value
130-
131-
132119
valid_dot_atom_characters = frozenset(string.ascii_letters + string.digits + ".!#$%&'*+-/=?^_`{|}~")
133120

134121

0 commit comments

Comments
 (0)