Message4115

Author leosoto
Recipients leosoto
Date 2009-02-02.02:39:56
SpamBayes Score 1.6969954e-08
Marked as misclassified No
Message-id <1233542397.93.0.472123912362.issue1257@psf.upfronthosting.co.za>
In-reply-to
Content
There are problems pickling instances of Django's MultiValueDict, only
when using protocol 2:

>>> from django.utils.datastructures import MultiValueDict
>>> d['a'] = 'b'
>>> pickle.loads(pickle.dumps(d, 2)) == d
False
>>> d
<MultiValueDict: {'a': ['b']}>
>>> pickle.loads(pickle.dumps(d, 2))
<MultiValueDict: {'a': [['b']]>

A zoom to the root of the problem:

>>> list(d.__reduce_ex__(2)[-1])
[('a', ['b'])]

Which is wrong. On CPython, it gives [('a', 'b')].

This is caused by not calling the custom itervalues() method of the
custom python class. The call which should be routed to the python
implementation is on PyObject#reduce_2(). The "routing" doesn't happen,
because PyDictDerived doesn't override itervalues(). 

Now, if we take the strategy of "routing" calls, I'm not sure how much
of the dict interface should we override on PyDictDerived to allow
forwarding java calls to the right place. All of it?

Another option would be to override __reduce__ on PyDictionaryDerived.
History
Date User Action Args
2009-02-02 02:39:58leosotosetrecipients: + leosoto
2009-02-02 02:39:57leosotosetmessageid: <1233542397.93.0.472123912362.issue1257@psf.upfronthosting.co.za>
2009-02-02 02:39:57leosotolinkissue1257 messages
2009-02-02 02:39:57leosotocreate