Code

Ticket #17965: stuff.diff

File stuff.diff, 7.7 KB (added by jonash, 2 years ago)
Line 
1commit facbc7981d9668312b189a21d94a4c60dd1d4342
2Author: Jonas Haag <jonas@lophus.org>
3Date:   Fri Mar 23 18:51:06 2012 +0100
4
5    stuff.patch
6
7diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
8index 4d2fefe..0368ca2 100644
9--- a/django/contrib/sessions/tests.py
10+++ b/django/contrib/sessions/tests.py
11@@ -404,10 +404,7 @@ class SessionMiddlewareTests(unittest.TestCase):
12 
13         # Handle the response through the middleware
14         response = middleware.process_response(request, response)
15-        # If it isn't in the cookie, that's fine (Python 2.5)
16-        if 'httponly' in settings.SESSION_COOKIE_NAME:
17-            self.assertFalse(
18-               response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
19+        self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
20 
21         self.assertNotIn('httponly',
22                          str(response.cookies[settings.SESSION_COOKIE_NAME]))
23diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py
24index 346deae..9eac8ec 100644
25--- a/django/core/cache/__init__.py
26+++ b/django/core/cache/__init__.py
27@@ -25,12 +25,7 @@ try:
28     # The mod_python version is more efficient, so try importing it first.
29     from mod_python.util import parse_qsl
30 except ImportError:
31-    try:
32-        # Python 2.6 and greater
33-        from urlparse import parse_qsl
34-    except ImportError:
35-        # Python 2.5.  Works on Python 2.6 but raises PendingDeprecationWarning
36-        from cgi import parse_qsl
37+    from urlparse import parse_qsl
38 
39 __all__ = [
40     'get_cache', 'cache', 'DEFAULT_CACHE_ALIAS'
41diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
42index 176ccef..2f1775e 100644
43--- a/django/core/management/commands/loaddata.py
44+++ b/django/core/management/commands/loaddata.py
45@@ -1,6 +1,3 @@
46-# This is necessary in Python 2.5 to enable the with statement, in 2.6
47-# and up it is no longer necessary.
48-
49 import sys
50 import os
51 import gzip
52@@ -15,7 +12,7 @@ from django.core.management.color import no_style
53 from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS,
54       IntegrityError, DatabaseError)
55 from django.db.models import get_apps
56-from django.utils.itercompat import product
57+from itertools import product
58 
59 try:
60     import bz2
61diff --git a/django/http/__init__.py b/django/http/__init__.py
62index 94478ae..5f407a4 100644
63--- a/django/http/__init__.py
64+++ b/django/http/__init__.py
65@@ -18,17 +18,9 @@ try:
66     # The mod_python version is more efficient, so try importing it first.
67     from mod_python.util import parse_qsl
68 except ImportError:
69-    try:
70-        # Python 2.6 and greater
71-        from urlparse import parse_qsl
72-    except ImportError:
73-        # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning
74-        from cgi import parse_qsl
75+    from urlparse import parse_qsl
76 
77 import Cookie
78-# httponly support exists in Python 2.6's Cookie library,
79-# but not in Python 2.5.
80-_morsel_supports_httponly = 'httponly' in Cookie.Morsel._reserved
81 # Some versions of Python 2.7 and later won't need this encoding bug fix:
82 _cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"')
83 # See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256
84@@ -39,28 +31,10 @@ try:
85 except Cookie.CookieError:
86     _cookie_allows_colon_in_names = False
87 
88-if _morsel_supports_httponly and _cookie_encodes_correctly and _cookie_allows_colon_in_names:
89+if _cookie_encodes_correctly and _cookie_allows_colon_in_names:
90     SimpleCookie = Cookie.SimpleCookie
91 else:
92-    if not _morsel_supports_httponly:
93-        class Morsel(Cookie.Morsel):
94-            def __setitem__(self, K, V):
95-                K = K.lower()
96-                if K == "httponly":
97-                    if V:
98-                        # The superclass rejects httponly as a key,
99-                        # so we jump to the grandparent.
100-                        super(Cookie.Morsel, self).__setitem__(K, V)
101-                else:
102-                    super(Morsel, self).__setitem__(K, V)
103-
104-            def OutputString(self, attrs=None):
105-                output = super(Morsel, self).OutputString(attrs)
106-                if "httponly" in self:
107-                    output += "; httponly"
108-                return output
109-    else:
110-        Morsel = Cookie.Morsel
111+    Morsel = Cookie.Morsel
112 
113     class SimpleCookie(Cookie.SimpleCookie):
114         if not _cookie_encodes_correctly:
115@@ -88,7 +62,7 @@ else:
116 
117                 return val, encoded
118 
119-        if not _cookie_allows_colon_in_names or not _morsel_supports_httponly:
120+        if not _cookie_allows_colon_in_names:
121             def load(self, rawdata):
122                 self.bad_cookies = set()
123                 super(SimpleCookie, self).load(rawdata)
124diff --git a/django/utils/http.py b/django/utils/http.py
125index d343a37..dbd18d8 100644
126--- a/django/utils/http.py
127+++ b/django/utils/http.py
128@@ -207,20 +207,9 @@ def quote_etag(etag):
129     """
130     return '"%s"' % etag.replace('\\', '\\\\').replace('"', '\\"')
131 
132-if sys.version_info >= (2, 6):
133-    def same_origin(url1, url2):
134-        """
135-        Checks if two URLs are 'same-origin'
136-        """
137-        p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
138-        return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)
139-else:
140-    # Python 2.5 compatibility. This actually works for Python 2.6 and above,
141-    # but the above definition is much more obviously correct and so is
142-    # preferred going forward.
143-    def same_origin(url1, url2):
144-        """
145-        Checks if two URLs are 'same-origin'
146-        """
147-        p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
148-        return p1[0:2] == p2[0:2]
149+def same_origin(url1, url2):
150+    """
151+    Checks if two URLs are 'same-origin'
152+    """
153+    p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
154+    return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)
155diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py
156index 82434b7..83a8bec 100644
157--- a/django/utils/itercompat.py
158+++ b/django/utils/itercompat.py
159@@ -7,23 +7,7 @@ these implementations if necessary.
160 import __builtin__
161 import itertools
162 import warnings
163-
164-# Fallback for Python 2.5
165-def product(*args, **kwds):
166-    """
167-    Taken from http://docs.python.org/library/itertools.html#itertools.product
168-    """
169-    # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
170-    # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
171-    pools = map(tuple, args) * kwds.get('repeat', 1)
172-    result = [[]]
173-    for pool in pools:
174-        result = [x+[y] for x in result for y in pool]
175-    for prod in result:
176-        yield tuple(prod)
177-
178-if hasattr(itertools, 'product'):
179-    product = itertools.product
180+from itertools import product
181 
182 def is_iterable(x):
183     "A implementation independent way of checking for iterables"
184diff --git a/setup.py b/setup.py
185index 1f14245..a19f660 100644
186--- a/setup.py
187+++ b/setup.py
188@@ -88,7 +88,6 @@ setup(
189         'License :: OSI Approved :: BSD License',
190         'Operating System :: OS Independent',
191         'Programming Language :: Python',
192-        'Programming Language :: Python :: 2.5',
193         'Programming Language :: Python :: 2.6',
194         'Programming Language :: Python :: 2.7',
195         'Topic :: Internet :: WWW/HTTP',
196diff --git a/tests/modeltests/serializers/tests.py b/tests/modeltests/serializers/tests.py
197index d474937..02538b0 100644
198--- a/tests/modeltests/serializers/tests.py
199+++ b/tests/modeltests/serializers/tests.py
200@@ -1,5 +1,3 @@
201-# This is necessary in Python 2.5 to enable the with statement, in 2.6
202-# and up it is no longer necessary.
203 from __future__ import absolute_import
204 
205 # -*- coding: utf-8 -*-