Pickle.dumps does not guarantee ASCII

This was falling in a mess on Postgres when the object being pickled contained encodings other than ASCII.

There's a discrepancy between the docs and reality which you can read about here: http://bugs.python.org/issue2980

I worked around by encoding to base64 before storing the picked object in the db, and then base64 decode on the way out.

Also elected to use the best available decoder seeing as there is no benefit to using the ASCII one (which doesn't guarantee ASCII).