Hi all

I was recently affected in production by a python bug:

http://bugs.python.org/issue826897

(also http://bugs.python.org/issue964868 , which refers to the problem
with Cookie)

The class affected by this bug is python's Cookie.Morsel. With the
bug, each time the object is pickled/unpickled, extra garbage is
appended to the cookie:

>>> import pickle
>>> from django.contrib.sessions.backends.db import SessionStore
>>> from django.http import HttpResponseRedirect
>>> rsp=HttpResponseRedirect('/foo/bar')
>>> rsp.set_cookie('Hello', '1', domain='foo.com')
>>> data = { 'rsp': rsp, }
>>> ss=SessionStore()
>>> encdata = ss.encode(data)
>>> data2=ss.decode(encdata)
>>> data2['rsp'].cookies
<SimpleCookie: Hello='Set-Cookie: Hello=1; Domain=foo.com; Path=/'>

The python bug is marked wont-fix. In our production code, we have
temporarily worked around it by forcing sessions to be encoded with
protocol 1 (binary) rather than protocol 2, by monkey patching
pickle.HIGHEST_PROTOCOL in settings.py.

Do you think it is right to use pickle.HIGHEST_PROTOCOL to pickle
session objects on branches that still support python 2.5? Given the
known issues with Cookie.Morsel, 2.5 and pickling, should Django
auto-monkey-patch this when it detects python 2.5?

Cheers

Tom

PS I'm quite happy with the answer 'Yes, you daft wally, you should be
using 2.7 AT LEAST by now anyway', as this gives me a business reason
to demand python upgrades all round :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to