Skip to content

Commit 174369a

Browse files
ngnpopefelixxm
authored andcommitted
Refs #34986 -- Avoided pickling error in DjangoUnicodeDecodeError.
By using the existing object reference instead of a custom one, pickling related issues when running the test suite in parallel can be avoided.
1 parent 0257426 commit 174369a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

django/utils/encoding.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99

1010

1111
class DjangoUnicodeDecodeError(UnicodeDecodeError):
12-
def __init__(self, obj, *args):
13-
self.obj = obj
14-
super().__init__(*args)
15-
1612
def __str__(self):
1713
return "%s. You passed in %r (%s)" % (
1814
super().__str__(),
19-
self.obj,
20-
type(self.obj),
15+
self.object,
16+
type(self.object),
2117
)
2218

2319

@@ -72,7 +68,7 @@ def force_str(s, encoding="utf-8", strings_only=False, errors="strict"):
7268
else:
7369
s = str(s)
7470
except UnicodeDecodeError as e:
75-
raise DjangoUnicodeDecodeError(s, *e.args)
71+
raise DjangoUnicodeDecodeError(*e.args) from None
7672
return s
7773

7874

0 commit comments

Comments
 (0)