Code

Ticket #17965: stuff_2.diff

File stuff_2.diff, 18.5 KB (added by claudep, 2 years ago)

Deprecate itercompat.product and more doc fixes

Line 
1diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
2index 89bcce8..dbcaea2 100644
3--- a/django/contrib/sessions/tests.py
4+++ b/django/contrib/sessions/tests.py
5@@ -407,10 +407,7 @@ class SessionMiddlewareTests(unittest.TestCase):
6 
7         # Handle the response through the middleware
8         response = middleware.process_response(request, response)
9-        # If it isn't in the cookie, that's fine (Python 2.5)
10-        if 'httponly' in settings.SESSION_COOKIE_NAME:
11-            self.assertFalse(
12-               response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
13+        self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
14 
15         self.assertNotIn('httponly',
16                          str(response.cookies[settings.SESSION_COOKIE_NAME]))
17diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py
18index 346deae..9eac8ec 100644
19--- a/django/core/cache/__init__.py
20+++ b/django/core/cache/__init__.py
21@@ -25,12 +25,7 @@ try:
22     # The mod_python version is more efficient, so try importing it first.
23     from mod_python.util import parse_qsl
24 except ImportError:
25-    try:
26-        # Python 2.6 and greater
27-        from urlparse import parse_qsl
28-    except ImportError:
29-        # Python 2.5.  Works on Python 2.6 but raises PendingDeprecationWarning
30-        from cgi import parse_qsl
31+    from urlparse import parse_qsl
32 
33 __all__ = [
34     'get_cache', 'cache', 'DEFAULT_CACHE_ALIAS'
35diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
36index 3e5b758..2f1775e 100644
37--- a/django/core/management/commands/loaddata.py
38+++ b/django/core/management/commands/loaddata.py
39@@ -12,7 +12,7 @@ from django.core.management.color import no_style
40 from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS,
41       IntegrityError, DatabaseError)
42 from django.db.models import get_apps
43-from django.utils.itercompat import product
44+from itertools import product
45 
46 try:
47     import bz2
48diff --git a/django/http/__init__.py b/django/http/__init__.py
49index 94478ae..5f407a4 100644
50--- a/django/http/__init__.py
51+++ b/django/http/__init__.py
52@@ -18,17 +18,9 @@ try:
53     # The mod_python version is more efficient, so try importing it first.
54     from mod_python.util import parse_qsl
55 except ImportError:
56-    try:
57-        # Python 2.6 and greater
58-        from urlparse import parse_qsl
59-    except ImportError:
60-        # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning
61-        from cgi import parse_qsl
62+    from urlparse import parse_qsl
63 
64 import Cookie
65-# httponly support exists in Python 2.6's Cookie library,
66-# but not in Python 2.5.
67-_morsel_supports_httponly = 'httponly' in Cookie.Morsel._reserved
68 # Some versions of Python 2.7 and later won't need this encoding bug fix:
69 _cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"')
70 # See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256
71@@ -39,28 +31,10 @@ try:
72 except Cookie.CookieError:
73     _cookie_allows_colon_in_names = False
74 
75-if _morsel_supports_httponly and _cookie_encodes_correctly and _cookie_allows_colon_in_names:
76+if _cookie_encodes_correctly and _cookie_allows_colon_in_names:
77     SimpleCookie = Cookie.SimpleCookie
78 else:
79-    if not _morsel_supports_httponly:
80-        class Morsel(Cookie.Morsel):
81-            def __setitem__(self, K, V):
82-                K = K.lower()
83-                if K == "httponly":
84-                    if V:
85-                        # The superclass rejects httponly as a key,
86-                        # so we jump to the grandparent.
87-                        super(Cookie.Morsel, self).__setitem__(K, V)
88-                else:
89-                    super(Morsel, self).__setitem__(K, V)
90-
91-            def OutputString(self, attrs=None):
92-                output = super(Morsel, self).OutputString(attrs)
93-                if "httponly" in self:
94-                    output += "; httponly"
95-                return output
96-    else:
97-        Morsel = Cookie.Morsel
98+    Morsel = Cookie.Morsel
99 
100     class SimpleCookie(Cookie.SimpleCookie):
101         if not _cookie_encodes_correctly:
102@@ -88,7 +62,7 @@ else:
103 
104                 return val, encoded
105 
106-        if not _cookie_allows_colon_in_names or not _morsel_supports_httponly:
107+        if not _cookie_allows_colon_in_names:
108             def load(self, rawdata):
109                 self.bad_cookies = set()
110                 super(SimpleCookie, self).load(rawdata)
111diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py
112index 82434b7..bc6f0fa 100644
113--- a/django/utils/itercompat.py
114+++ b/django/utils/itercompat.py
115@@ -5,26 +5,8 @@ these implementations if necessary.
116 """
117 
118 import __builtin__
119-import itertools
120 import warnings
121 
122-# Fallback for Python 2.5
123-def product(*args, **kwds):
124-    """
125-    Taken from http://docs.python.org/library/itertools.html#itertools.product
126-    """
127-    # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
128-    # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
129-    pools = map(tuple, args) * kwds.get('repeat', 1)
130-    result = [[]]
131-    for pool in pools:
132-        result = [x+[y] for x in result for y in pool]
133-    for prod in result:
134-        yield tuple(prod)
135-
136-if hasattr(itertools, 'product'):
137-    product = itertools.product
138-
139 def is_iterable(x):
140     "A implementation independent way of checking for iterables"
141     try:
142@@ -34,6 +16,13 @@ def is_iterable(x):
143     else:
144         return True
145 
146+def product(*args, **kwds):
147+    # PendingDeprecationWarning in 1.5, remove this comment when the Deprecations
148+    # will have been advanced for 1.5
149+    warnings.warn("django.utils.itercompat.product is deprecated; use the native version instead",
150+                  PendingDeprecationWarning)
151+    return __builtin__.product(*args, **kwds)
152+
153 def all(iterable):
154     warnings.warn("django.utils.itercompat.all is deprecated; use the native version instead",
155                   PendingDeprecationWarning)
156diff --git a/docs/faq/install.txt b/docs/faq/install.txt
157index c5847d3..8021229 100644
158--- a/docs/faq/install.txt
159+++ b/docs/faq/install.txt
160@@ -16,7 +16,7 @@ How do I get started?
161 What are Django's prerequisites?
162 --------------------------------
163 
164-Django requires Python_, specifically any version of Python from 2.5
165+Django requires Python_, specifically any version of Python from 2.6
166 through 2.7. No other Python libraries are required for basic Django
167 usage.
168 
169@@ -39,15 +39,14 @@ PostgreSQL fans, and MySQL_, `SQLite 3`_, and Oracle_ are also supported.
170 .. _`SQLite 3`: http://www.sqlite.org/
171 .. _Oracle: http://www.oracle.com/
172 
173-Do I lose anything by using Python 2.5 versus newer Python versions, such as Python 2.6 or 2.7?
174------------------------------------------------------------------------------------------------
175+Do I lose anything by using Python 2.6 versus newer Python versions, such as Python 2.7?
176+----------------------------------------------------------------------------------------
177 
178 Not in the core framework. Currently, Django itself officially supports any
179-version of Python from 2.5 through 2.7, inclusive. However, newer versions of
180+version of Python from 2.6 through 2.7, inclusive. However, newer versions of
181 Python are often faster, have more features, and are better supported. If you
182 use a newer version of Python you will also have access to some APIs that
183-aren't available under older versions of Python. For example, since Python 2.6,
184-you can use the advanced string formatting described in :pep:`3101`.
185+aren't available under older versions of Python.
186 
187 Third-party applications for use with Django are, of course, free to set their
188 own version requirements.
189@@ -58,7 +57,7 @@ versions as part of a migration which will end with Django running on Python 3
190 
191 All else being equal, we recommend that you use the latest 2.x release
192 (currently Python 2.7). This will let you take advantage of the numerous
193-improvements and optimizations to the Python language since version 2.5, and
194+improvements and optimizations to the Python language since version 2.6, and
195 will help ease the process of dropping support for older Python versions on
196 the road to Python 3.
197 
198diff --git a/docs/howto/jython.txt b/docs/howto/jython.txt
199index 68f8378..5b11a88 100644
200--- a/docs/howto/jython.txt
201+++ b/docs/howto/jython.txt
202@@ -4,6 +4,12 @@ Running Django on Jython
203 
204 .. index:: Jython, Java, JVM
205 
206+.. admonition::
207+
208+    Django 1.5 has dropped support for Python 2.5. Until Jython provides a new
209+    version that supports 2.6, Django 1.5 is no more compatible with Jython.
210+    Please use Django 1.4 if you want to use Django over Jython.
211+
212 Jython_ is an implementation of Python that runs on the Java platform (JVM).
213 Django runs cleanly on Jython version 2.5 or later, which means you can deploy
214 Django on any Java platform.
215diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
216index 81ca7af..66791e6 100644
217--- a/docs/internals/deprecation.txt
218+++ b/docs/internals/deprecation.txt
219@@ -7,20 +7,6 @@ in a backward incompatible way, following their deprecation, as per the
220 :ref:`deprecation policy <internal-release-deprecation-policy>`. More details
221 about each item can often be found in the release notes of two versions prior.
222 
223-1.3
224----
225-
226-See the :doc:`Django 1.1 release notes</releases/1.1>` for more details on
227-these changes.
228-
229-* ``AdminSite.root()``.  This method of hooking up the admin URLs will be
230-  removed in favor of including ``admin.site.urls``.
231-
232-* Authentication backends need to define the boolean attributes
233-  ``supports_object_permissions`` and ``supports_anonymous_user`` until
234-  version 1.4, at which point it will be assumed that all backends will
235-  support these options.
236-
237 1.4
238 ---
239 
240@@ -276,6 +262,15 @@ these changes.
241   in 1.4. The backward compatibility will be removed --
242   ``HttpRequest.raw_post_data`` will no longer work.
243 
244+1.7
245+---
246+
247+See the :doc:`Django 1.5 release notes</releases/1.5>` for more details on
248+these changes.
249+
250+* The function ``django.utils.itercompat.product`` will be removed. The Python
251+  builtin version should be used instead.
252+
253 2.0
254 ---
255 
256diff --git a/docs/intro/install.txt b/docs/intro/install.txt
257index 1efd182..ef04eba 100644
258--- a/docs/intro/install.txt
259+++ b/docs/intro/install.txt
260@@ -10,7 +10,7 @@ Install Python
261 --------------
262 
263 Being a Python Web framework, Django requires Python. It works with any Python
264-version from 2.5 to 2.7 (due to backwards incompatibilities in Python 3.0,
265+version from 2.6 to 2.7 (due to backwards incompatibilities in Python 3.0,
266 Django does not currently work with Python 3.0; see :doc:`the Django FAQ
267 </faq/install>` for more information on supported Python versions and the 3.0
268 transition), these versions of Python include a lightweight database called
269@@ -31,15 +31,15 @@ probably already have it installed.
270 You can verify that Python is installed by typing ``python`` from your shell;
271 you should see something like::
272 
273-    Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
274-    [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
275+    Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
276+    [GCC 4.4.5] on linux2
277     Type "help", "copyright", "credits" or "license" for more information.
278     >>>
279 
280 Set up a database
281 -----------------
282 
283-If you installed Python 2.5 or later, you can skip this step for now.
284+If you installed Python 2.6 or later, you can skip this step for now.
285 
286 If not, or if you'd like to work with a "large" database engine like PostgreSQL,
287 MySQL, or Oracle, consult the :ref:`database installation information
288diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt
289index d375640..7575afd 100644
290--- a/docs/intro/tutorial01.txt
291+++ b/docs/intro/tutorial01.txt
292@@ -221,9 +221,8 @@ your database connection settings.
293 
294 If you're new to databases, we recommend simply using SQLite by setting
295 :setting:`ENGINE` to ``'django.db.backends.sqlite3'`` and :setting:`NAME` to
296-the place where you'd like to store the database. SQLite is included as part
297-of Python 2.5 and later, so you won't need to install anything else to support
298-your database.
299+the place where you'd like to store the database. SQLite is included in Python,
300+so you won't need to install anything else to support your database.
301 
302 .. note::
303 
304diff --git a/docs/ref/contrib/gis/deployment.txt b/docs/ref/contrib/gis/deployment.txt
305index 4cea022..c50a378 100644
306--- a/docs/ref/contrib/gis/deployment.txt
307+++ b/docs/ref/contrib/gis/deployment.txt
308@@ -37,8 +37,8 @@ Example::
309       WSGIProcessGroup geodjango
310       WSGIScriptAlias / /home/geo/geodjango/world.wsgi
311 
312-      Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/"
313-      <Directory "/usr/lib/python2.5/site-packages/django/contrib/admin/media/">
314+      Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/"
315+      <Directory "/usr/lib/python2.6/site-packages/django/contrib/admin/media/">
316         Order allow,deny
317         Options Indexes
318         Allow from all
319@@ -77,7 +77,7 @@ Example::
320         PythonPath "['/var/www/apps'] + sys.path"
321       </Location>
322 
323-      Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/"
324+      Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/"
325       <Location "/media">
326         SetHandler None
327       </Location>
328diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
329index f0b485f..59a0c36 100644
330--- a/docs/ref/databases.txt
331+++ b/docs/ref/databases.txt
332@@ -461,17 +461,6 @@ SQLite 3.3.6 was released in April 2006, so most current binary distributions
333 for different platforms include newer version of SQLite usable from Python
334 through either the ``pysqlite2`` or the ``sqlite3`` modules.
335 
336-However, some platform/Python version combinations include older versions of
337-SQLite (e.g. the official binary distribution of Python 2.5 for Windows, 2.5.4
338-as of this writing, includes SQLite 3.3.4). There are (as of Django 1.1) even
339-some tests in the Django test suite that will fail when run under this setup.
340-
341-As described :ref:`below<using-newer-versions-of-pysqlite>`, this can be solved
342-by downloading and installing a newer version of ``pysqlite2``
343-(``pysqlite-2.x.x.win32-py2.5.exe`` in the described case) that includes and
344-uses a newer version of SQLite. Python 2.6 for Windows ships with a version of
345-SQLite that is not affected by these issues.
346-
347 Version 3.5.9
348 -------------
349 
350diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
351index c8887c2..84459f9 100644
352--- a/docs/releases/1.5.txt
353+++ b/docs/releases/1.5.txt
354@@ -39,3 +39,8 @@ Backwards incompatible changes in 1.5
355 Features deprecated in 1.5
356 ==========================
357 
358+itercompat.product
359+~~~~~~~~~~~~~~~~~~
360+
361+The :func:`~django.utils.itercompat.product` function has been deprecated. Use
362+the builtin `itertools.product` instead.
363diff --git a/docs/topics/db/transactions.txt b/docs/topics/db/transactions.txt
364index 0f0b52a..589ebc7 100644
365--- a/docs/topics/db/transactions.txt
366+++ b/docs/topics/db/transactions.txt
367@@ -93,9 +93,7 @@ These functions, described in detail below, can be used in two different ways:
368             # this code executes inside a transaction
369             # ...
370 
371-Both techniques work with all supported version of Python. However, in Python
372-2.5, you must add ``from __future__ import with_statement`` at the beginning
373-of your module if you are using the ``with`` statement.
374+Both techniques work with all supported version of Python.
375 
376 .. _decorator: http://docs.python.org/glossary.html#term-decorator
377 .. _context manager: http://docs.python.org/glossary.html#term-context-manager
378diff --git a/docs/topics/install.txt b/docs/topics/install.txt
379index e91c3e0..728ea05 100644
380--- a/docs/topics/install.txt
381+++ b/docs/topics/install.txt
382@@ -9,7 +9,7 @@ Install Python
383 
384 Being a Python Web framework, Django requires Python.
385 
386-It works with any Python version from 2.5 to 2.7 (due to backwards
387+It works with any Python version from 2.6 to 2.7 (due to backwards
388 incompatibilities in Python 3.0, Django does not currently work with
389 Python 3.0; see :doc:`the Django FAQ </faq/install>` for more
390 information on supported Python versions and the 3.0 transition).
391diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
392index 39f0770..ad798de 100644
393--- a/docs/topics/testing.txt
394+++ b/docs/topics/testing.txt
395@@ -1591,10 +1591,6 @@ your test suite.
396 
397     You can use this as a context manager, like this::
398 
399-        # This is necessary in Python 2.5 to enable the with statement.
400-        # In 2.6 and up, it's not necessary.
401-        from __future__ import with_statement
402-
403         with self.assertTemplateUsed('index.html'):
404             render_to_string('index.html')
405         with self.assertTemplateUsed(template_name='index.html'):
406@@ -1656,12 +1652,7 @@ your test suite.
407 
408         self.assertNumQueries(7, lambda: my_function(using=7))
409 
410-    If you're using Python 2.5 or greater you can also use this as a context
411-    manager::
412-
413-        # This is necessary in Python 2.5 to enable the with statement, in 2.6
414-        # and up it is no longer necessary.
415-        from __future__ import with_statement
416+    You can also use this as a context manager::
417 
418         with self.assertNumQueries(2):
419             Person.objects.create(name="Aaron")
420diff --git a/setup.py b/setup.py
421index 1f14245..a19f660 100644
422--- a/setup.py
423+++ b/setup.py
424@@ -88,7 +88,6 @@ setup(
425         'License :: OSI Approved :: BSD License',
426         'Operating System :: OS Independent',
427         'Programming Language :: Python',
428-        'Programming Language :: Python :: 2.5',
429         'Programming Language :: Python :: 2.6',
430         'Programming Language :: Python :: 2.7',
431         'Topic :: Internet :: WWW/HTTP',
432diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py
433index ce15b8b..2499b7a 100644
434--- a/tests/regressiontests/forms/tests/widgets.py
435+++ b/tests/regressiontests/forms/tests/widgets.py
436@@ -25,8 +25,6 @@ class FormsWidgetTestCase(TestCase):
437         self.assertHTMLEqual(w.render('email', 'some "quoted" & ampersanded value'), u'<input type="text" name="email" value="some &quot;quoted&quot; &amp; ampersanded value" />')
438         self.assertHTMLEqual(w.render('email', 'test@example.com', attrs={'class': 'fun'}), u'<input type="text" name="email" value="test@example.com" class="fun" />')
439 
440-        # Note that doctest in Python 2.4 (and maybe 2.5?) doesn't support non-ascii
441-        # characters in output, so we're displaying the repr() here.
442         self.assertHTMLEqual(w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}), u'<input type="text" name="email" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" class="fun" />')
443 
444         # You can also pass 'attrs' to the constructor: