diff --git a/django/http/__init__.py b/django/http/__init__.py index 683212fcd4b..446659b5601 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