Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.1.X] Fixed edge case that breaks the test suite on versions of Pyt…

…hon > 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.

Backport of r11820 from trunk

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11821 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 512ee70527e1b0c30a4db21d10f0129e00b7d991 1 parent cf844fd
@brosner brosner authored
Showing with 10 additions and 8 deletions.
  1. +10 −8 django/http/__init__.py
View
18 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 @@ def urlencode(self):
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
Please sign in to comment.
Something went wrong with that request. Please try again.