Ticket #17965: stuff.diff
File stuff.diff, 7.7 KB (added by , 13 years ago) |
---|
-
django/contrib/sessions/tests.py
commit facbc7981d9668312b189a21d94a4c60dd1d4342 Author: Jonas Haag <jonas@lophus.org> Date: Fri Mar 23 18:51:06 2012 +0100 stuff.patch diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py index 4d2fefe..0368ca2 100644
a b class SessionMiddlewareTests(unittest.TestCase): 404 404 405 405 # Handle the response through the middleware 406 406 response = middleware.process_response(request, response) 407 # If it isn't in the cookie, that's fine (Python 2.5) 408 if 'httponly' in settings.SESSION_COOKIE_NAME: 409 self.assertFalse( 410 response.cookies[settings.SESSION_COOKIE_NAME]['httponly']) 407 self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly']) 411 408 412 409 self.assertNotIn('httponly', 413 410 str(response.cookies[settings.SESSION_COOKIE_NAME])) -
django/core/cache/__init__.py
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index 346deae..9eac8ec 100644
a b try: 25 25 # The mod_python version is more efficient, so try importing it first. 26 26 from mod_python.util import parse_qsl 27 27 except ImportError: 28 try: 29 # Python 2.6 and greater 30 from urlparse import parse_qsl 31 except ImportError: 32 # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning 33 from cgi import parse_qsl 28 from urlparse import parse_qsl 34 29 35 30 __all__ = [ 36 31 'get_cache', 'cache', 'DEFAULT_CACHE_ALIAS' -
django/core/management/commands/loaddata.py
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py index 176ccef..2f1775e 100644
a b 1 # This is necessary in Python 2.5 to enable the with statement, in 2.62 # and up it is no longer necessary.3 4 1 import sys 5 2 import os 6 3 import gzip … … from django.core.management.color import no_style 15 12 from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS, 16 13 IntegrityError, DatabaseError) 17 14 from django.db.models import get_apps 18 from django.utils.itercompatimport product15 from itertools import product 19 16 20 17 try: 21 18 import bz2 -
django/http/__init__.py
diff --git a/django/http/__init__.py b/django/http/__init__.py index 94478ae..5f407a4 100644
a b try: 18 18 # The mod_python version is more efficient, so try importing it first. 19 19 from mod_python.util import parse_qsl 20 20 except ImportError: 21 try: 22 # Python 2.6 and greater 23 from urlparse import parse_qsl 24 except ImportError: 25 # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning 26 from cgi import parse_qsl 21 from urlparse import parse_qsl 27 22 28 23 import Cookie 29 # httponly support exists in Python 2.6's Cookie library,30 # but not in Python 2.5.31 _morsel_supports_httponly = 'httponly' in Cookie.Morsel._reserved32 24 # Some versions of Python 2.7 and later won't need this encoding bug fix: 33 25 _cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"') 34 26 # See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256 … … try: 39 31 except Cookie.CookieError: 40 32 _cookie_allows_colon_in_names = False 41 33 42 if _ morsel_supports_httponly and _cookie_encodes_correctly and _cookie_allows_colon_in_names:34 if _cookie_encodes_correctly and _cookie_allows_colon_in_names: 43 35 SimpleCookie = Cookie.SimpleCookie 44 36 else: 45 if not _morsel_supports_httponly: 46 class Morsel(Cookie.Morsel): 47 def __setitem__(self, K, V): 48 K = K.lower() 49 if K == "httponly": 50 if V: 51 # The superclass rejects httponly as a key, 52 # so we jump to the grandparent. 53 super(Cookie.Morsel, self).__setitem__(K, V) 54 else: 55 super(Morsel, self).__setitem__(K, V) 56 57 def OutputString(self, attrs=None): 58 output = super(Morsel, self).OutputString(attrs) 59 if "httponly" in self: 60 output += "; httponly" 61 return output 62 else: 63 Morsel = Cookie.Morsel 37 Morsel = Cookie.Morsel 64 38 65 39 class SimpleCookie(Cookie.SimpleCookie): 66 40 if not _cookie_encodes_correctly: … … else: 88 62 89 63 return val, encoded 90 64 91 if not _cookie_allows_colon_in_names or not _morsel_supports_httponly:65 if not _cookie_allows_colon_in_names: 92 66 def load(self, rawdata): 93 67 self.bad_cookies = set() 94 68 super(SimpleCookie, self).load(rawdata) -
django/utils/http.py
diff --git a/django/utils/http.py b/django/utils/http.py index d343a37..dbd18d8 100644
a b def quote_etag(etag): 207 207 """ 208 208 return '"%s"' % etag.replace('\\', '\\\\').replace('"', '\\"') 209 209 210 if sys.version_info >= (2, 6): 211 def same_origin(url1, url2): 212 """ 213 Checks if two URLs are 'same-origin' 214 """ 215 p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2) 216 return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port) 217 else: 218 # Python 2.5 compatibility. This actually works for Python 2.6 and above, 219 # but the above definition is much more obviously correct and so is 220 # preferred going forward. 221 def same_origin(url1, url2): 222 """ 223 Checks if two URLs are 'same-origin' 224 """ 225 p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2) 226 return p1[0:2] == p2[0:2] 210 def same_origin(url1, url2): 211 """ 212 Checks if two URLs are 'same-origin' 213 """ 214 p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2) 215 return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port) -
django/utils/itercompat.py
diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py index 82434b7..83a8bec 100644
a b these implementations if necessary. 7 7 import __builtin__ 8 8 import itertools 9 9 import warnings 10 11 # Fallback for Python 2.5 12 def product(*args, **kwds): 13 """ 14 Taken from http://docs.python.org/library/itertools.html#itertools.product 15 """ 16 # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy 17 # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111 18 pools = map(tuple, args) * kwds.get('repeat', 1) 19 result = [[]] 20 for pool in pools: 21 result = [x+[y] for x in result for y in pool] 22 for prod in result: 23 yield tuple(prod) 24 25 if hasattr(itertools, 'product'): 26 product = itertools.product 10 from itertools import product 27 11 28 12 def is_iterable(x): 29 13 "A implementation independent way of checking for iterables" -
setup.py
diff --git a/setup.py b/setup.py index 1f14245..a19f660 100644
a b setup( 88 88 'License :: OSI Approved :: BSD License', 89 89 'Operating System :: OS Independent', 90 90 'Programming Language :: Python', 91 'Programming Language :: Python :: 2.5',92 91 'Programming Language :: Python :: 2.6', 93 92 'Programming Language :: Python :: 2.7', 94 93 'Topic :: Internet :: WWW/HTTP', -
tests/modeltests/serializers/tests.py
diff --git a/tests/modeltests/serializers/tests.py b/tests/modeltests/serializers/tests.py index d474937..02538b0 100644
a b 1 # This is necessary in Python 2.5 to enable the with statement, in 2.62 # and up it is no longer necessary.3 1 from __future__ import absolute_import 4 2 5 3 # -*- coding: utf-8 -*-