diff options
| author | Brian Rosner <brosner@gmail.com> | 2009-12-12 15:30:25 +0000 |
|---|---|---|
| committer | Brian Rosner <brosner@gmail.com> | 2009-12-12 15:30:25 +0000 |
| commit | 2659429df46d0d79ad7a93d50d0ccdab45b55b53 (patch) | |
| tree | 0844093788f52a8d521caa196ed19e340d29e579 | |
| parent | 85def09554708deca317f9f7e57adf13c5514c40 (diff) | |
Fixed edge case that breaks the test suite on versions of Python > 2.6.4
Before http://svn.python.org/view?view=rev&revision=74647 it was possible to
pass a SimpleCookie to load, but this no longer works due to a different bug
in Python the said revision fixed.
My guess is a SimpleCookie was never intended to be passed through load which
is perfectly reasonable.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11820 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/http/__init__.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py index 683212fcd4..446659b560 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -1,6 +1,6 @@ import os import re -from Cookie import SimpleCookie, CookieError +from Cookie import BaseCookie, SimpleCookie, CookieError from pprint import pformat from urllib import urlencode from urlparse import urljoin @@ -251,13 +251,15 @@ class QueryDict(MultiValueDict): def parse_cookie(cookie): if cookie == '': return {} - try: - c = SimpleCookie() - c.load(cookie) - except CookieError: - # Invalid cookie - return {} - + if not isinstance(cookie, BaseCookie): + try: + c = SimpleCookie() + c.load(cookie) + except CookieError: + # Invalid cookie + return {} + else: + c = cookie cookiedict = {} for key in c.keys(): cookiedict[key] = c.get(key).value |
