1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

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.
This commit is contained in:
Nick Pope 2023-11-21 15:37:28 +00:00 committed by Mariusz Felisiak
parent 0257426fe1
commit 174369a990

View File

@ -9,15 +9,11 @@ from django.utils.functional import Promise
class DjangoUnicodeDecodeError(UnicodeDecodeError):
def __init__(self, obj, *args):
self.obj = obj
super().__init__(*args)
def __str__(self):
return "%s. You passed in %r (%s)" % (
super().__str__(),
self.obj,
type(self.obj),
self.object,
type(self.object),
)
@ -72,7 +68,7 @@ def force_str(s, encoding="utf-8", strings_only=False, errors="strict"):
else:
s = str(s)
except UnicodeDecodeError as e:
raise DjangoUnicodeDecodeError(s, *e.args)
raise DjangoUnicodeDecodeError(*e.args) from None
return s