Serializing Django's ErrorList results in invalid bytes
LilyFirefly opened this issue · 1 comments
LilyFirefly commented
I've created a minimal example.
# msgpack_errorlist.tests
from unittest import TestCase
import msgpack
from django.forms.utils import ErrorList
class MsgpackTestCase(TestCase):
def test_errorlist(self):
data = ErrorList("T")
raw = msgpack.packb(data)
msgpack.unpackb(raw)msgpack_errorlist$ python manage.py test
Found 1 test(s).
System check identified no issues (0 silenced).
E
======================================================================
ERROR: test_errorlist (msgpack_errorlist.tests.MsgpackTestCase.test_errorlist)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/lily/work/kloppindustries/msgpack_errorlist/msgpack_errorlist/tests.py", line 13, in test_errorlist
msgpack.unpackb(raw)
File "msgpack/_unpacker.pyx", line 201, in msgpack._cmsgpack.unpackb
msgpack.exceptions.ExtraData: unpack(b) received extra data.
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
The invalid msgpack bytes are: \x90\xa1T.
My unproven suspicion is that this is something to do with ErrorList subclassing list.
LilyFoote commented
Ah! I just discovered the strict_types flag! Using that solves this for me.