Skip to content Skip to sidebar Skip to footer

Python Pickling Error When Using Sessions

In my django app I was creating an extended user profile using session vars. But when registration form was saved and user was about to create, I got following error : Traceback (m

Solution 1:

It appears you have a cStringIO object in your session (perhaps an uploaded file?), these cannot be pickled. Either write custom pickling code or make sure all your session data can be serialized.

Solution 2:

Something weird going on here, because the error refers to cStringIO.StringO whereas the class is actually cStringIO.StringIO, with an extra I. Have you misspelled the name somewhere?

Solution 3:

In support of Ivo's answer, here's a reference I found which may explain this: http://bugs.python.org/issue5345

This is not a typo. cStringIO.StringIO is a factory function that returns either a cStringO object (for writing) or cStringI (for reading). If this behavior causes a problem to you, then consider using StringIO.StringIO.

Alternatively, you could upgrade to Python 2.7 or 3.0 and use io.StringIO() which doesn't have this limitation.

Post a Comment for "Python Pickling Error When Using Sessions"