mozilla / elasticutils

[deprecated] A friendly chainable ElasticSearch interface for python
http://elasticutils.rtfd.org
BSD 3-Clause "New" or "Revised" License
243 stars 76 forks source link

Fix infinite recursion when unpickling a mapping type instance #263

Closed batlock666 closed 9 years ago

batlock666 commented 9 years ago

I noticed that unpickling mapping type instances led to infinite recursion. This happened when I tried to cache search results in Django (using django.core.cache).

Reproducing the problem:

# mt is a mapping type instance
import pickle
pickled = pickle.dumps(mt, 2)
unpickled = pickle.loads(pickled)

This should lead to a RuntimeError because of the infinite recursion. The fix prevents this from happening.

willkg commented 9 years ago

Can you add a test case for this?

willkg commented 9 years ago

Nevermind. I wrote one.