From 23d34597615d8209de72bd819539a696ba0d1e7f Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 31 Mar 2012 08:24:29 +0000 Subject: [PATCH] Fixed #17965 -- Definitely dropped support for Python 2.5. Thanks jonash for the initial patch and Aymeric Augustin for the review. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17834 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/sessions/tests.py | 5 +-- django/core/cache/__init__.py | 7 +--- django/core/management/commands/loaddata.py | 2 +- django/http/__init__.py | 34 +++----------------- django/utils/itercompat.py | 24 ++++---------- docs/faq/install.txt | 18 +++++------ docs/howto/jython.txt | 6 ++++ docs/internals/deprecation.txt | 23 ++++++------- docs/intro/install.txt | 8 ++--- docs/intro/tutorial01.txt | 5 ++- docs/ref/contrib/gis/deployment.txt | 6 ++-- docs/ref/databases.txt | 11 ------- docs/releases/1.5.txt | 5 +++ docs/topics/db/transactions.txt | 4 +-- docs/topics/install.txt | 2 +- docs/topics/testing.txt | 11 +------ setup.py | 1 - tests/regressiontests/forms/tests/widgets.py | 2 -- 18 files changed, 54 insertions(+), 120 deletions(-) diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py index 89bcce84ff..dbcaea2874 100644 --- a/django/contrib/sessions/tests.py +++ b/django/contrib/sessions/tests.py @@ -407,10 +407,7 @@ class SessionMiddlewareTests(unittest.TestCase): # Handle the response through the middleware response = middleware.process_response(request, response) - # If it isn't in the cookie, that's fine (Python 2.5) - if 'httponly' in settings.SESSION_COOKIE_NAME: - self.assertFalse( - response.cookies[settings.SESSION_COOKIE_NAME]['httponly']) + self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly']) self.assertNotIn('httponly', str(response.cookies[settings.SESSION_COOKIE_NAME])) diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index 346deae916..9eac8ec8fe 100644 --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -25,12 +25,7 @@ try: # The mod_python version is more efficient, so try importing it first. from mod_python.util import parse_qsl except ImportError: - try: - # Python 2.6 and greater - from urlparse import parse_qsl - except ImportError: - # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning - from cgi import parse_qsl + from urlparse import parse_qsl __all__ = [ 'get_cache', 'cache', 'DEFAULT_CACHE_ALIAS' diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py index 3e5b7584f3..2f1775e271 100644 --- a/django/core/management/commands/loaddata.py +++ b/django/core/management/commands/loaddata.py @@ -12,7 +12,7 @@ from django.core.management.color import no_style from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS, IntegrityError, DatabaseError) from django.db.models import get_apps -from django.utils.itercompat import product +from itertools import product try: import bz2 diff --git a/django/http/__init__.py b/django/http/__init__.py index 94478ae5ae..5f407a4403 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -18,17 +18,9 @@ try: # The mod_python version is more efficient, so try importing it first. from mod_python.util import parse_qsl except ImportError: - try: - # Python 2.6 and greater - from urlparse import parse_qsl - except ImportError: - # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning - from cgi import parse_qsl + from urlparse import parse_qsl import Cookie -# httponly support exists in Python 2.6's Cookie library, -# but not in Python 2.5. -_morsel_supports_httponly = 'httponly' in Cookie.Morsel._reserved # Some versions of Python 2.7 and later won't need this encoding bug fix: _cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"') # See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256 @@ -39,28 +31,10 @@ try: except Cookie.CookieError: _cookie_allows_colon_in_names = False -if _morsel_supports_httponly and _cookie_encodes_correctly and _cookie_allows_colon_in_names: +if _cookie_encodes_correctly and _cookie_allows_colon_in_names: SimpleCookie = Cookie.SimpleCookie else: - if not _morsel_supports_httponly: - class Morsel(Cookie.Morsel): - def __setitem__(self, K, V): - K = K.lower() - if K == "httponly": - if V: - # The superclass rejects httponly as a key, - # so we jump to the grandparent. - super(Cookie.Morsel, self).__setitem__(K, V) - else: - super(Morsel, self).__setitem__(K, V) - - def OutputString(self, attrs=None): - output = super(Morsel, self).OutputString(attrs) - if "httponly" in self: - output += "; httponly" - return output - else: - Morsel = Cookie.Morsel + Morsel = Cookie.Morsel class SimpleCookie(Cookie.SimpleCookie): if not _cookie_encodes_correctly: @@ -88,7 +62,7 @@ else: return val, encoded - if not _cookie_allows_colon_in_names or not _morsel_supports_httponly: + if not _cookie_allows_colon_in_names: def load(self, rawdata): self.bad_cookies = set() super(SimpleCookie, self).load(rawdata) diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py index 82434b7c9b..dd47b7df24 100644 --- a/django/utils/itercompat.py +++ b/django/utils/itercompat.py @@ -8,23 +8,6 @@ import __builtin__ import itertools import warnings -# Fallback for Python 2.5 -def product(*args, **kwds): - """ - Taken from http://docs.python.org/library/itertools.html#itertools.product - """ - # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy - # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111 - pools = map(tuple, args) * kwds.get('repeat', 1) - result = [[]] - for pool in pools: - result = [x+[y] for x in result for y in pool] - for prod in result: - yield tuple(prod) - -if hasattr(itertools, 'product'): - product = itertools.product - def is_iterable(x): "A implementation independent way of checking for iterables" try: @@ -34,6 +17,13 @@ def is_iterable(x): else: return True +def product(*args, **kwds): + # PendingDeprecationWarning in 1.5, remove this comment when the Deprecations + # will have been advanced for 1.5 + warnings.warn("django.utils.itercompat.product is deprecated; use the native version instead", + PendingDeprecationWarning) + return itertools.product(*args, **kwds) + def all(iterable): warnings.warn("django.utils.itercompat.all is deprecated; use the native version instead", PendingDeprecationWarning) diff --git a/docs/faq/install.txt b/docs/faq/install.txt index c5847d3145..e2ecfb4717 100644 --- a/docs/faq/install.txt +++ b/docs/faq/install.txt @@ -16,9 +16,8 @@ How do I get started? What are Django's prerequisites? -------------------------------- -Django requires Python_, specifically any version of Python from 2.5 -through 2.7. No other Python libraries are required for basic Django -usage. +Django requires Python_, specifically Python 2.6 or 2.7. +No other Python libraries are required for basic Django usage. For a development environment -- if you just want to experiment with Django -- you don't need to have a separate Web server installed; Django comes with its @@ -39,15 +38,14 @@ PostgreSQL fans, and MySQL_, `SQLite 3`_, and Oracle_ are also supported. .. _`SQLite 3`: http://www.sqlite.org/ .. _Oracle: http://www.oracle.com/ -Do I lose anything by using Python 2.5 versus newer Python versions, such as Python 2.6 or 2.7? ------------------------------------------------------------------------------------------------ +Do I lose anything by using Python 2.6 versus newer Python versions, such as Python 2.7? +---------------------------------------------------------------------------------------- -Not in the core framework. Currently, Django itself officially supports any -version of Python from 2.5 through 2.7, inclusive. However, newer versions of +Not in the core framework. Currently, Django itself officially supports +Python 2.6 and 2.7. However, newer versions of Python are often faster, have more features, and are better supported. If you use a newer version of Python you will also have access to some APIs that -aren't available under older versions of Python. For example, since Python 2.6, -you can use the advanced string formatting described in :pep:`3101`. +aren't available under older versions of Python. Third-party applications for use with Django are, of course, free to set their own version requirements. @@ -58,7 +56,7 @@ versions as part of a migration which will end with Django running on Python 3 All else being equal, we recommend that you use the latest 2.x release (currently Python 2.7). This will let you take advantage of the numerous -improvements and optimizations to the Python language since version 2.5, and +improvements and optimizations to the Python language since version 2.6, and will help ease the process of dropping support for older Python versions on the road to Python 3. diff --git a/docs/howto/jython.txt b/docs/howto/jython.txt index 68f83786e5..5b11a883d9 100644 --- a/docs/howto/jython.txt +++ b/docs/howto/jython.txt @@ -4,6 +4,12 @@ Running Django on Jython .. index:: Jython, Java, JVM +.. admonition:: + + Django 1.5 has dropped support for Python 2.5. Until Jython provides a new + version that supports 2.6, Django 1.5 is no more compatible with Jython. + Please use Django 1.4 if you want to use Django over Jython. + Jython_ is an implementation of Python that runs on the Java platform (JVM). Django runs cleanly on Jython version 2.5 or later, which means you can deploy Django on any Java platform. diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 81ca7afa27..66791e65db 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -7,20 +7,6 @@ in a backward incompatible way, following their deprecation, as per the :ref:`deprecation policy `. More details about each item can often be found in the release notes of two versions prior. -1.3 ---- - -See the :doc:`Django 1.1 release notes` for more details on -these changes. - -* ``AdminSite.root()``. This method of hooking up the admin URLs will be - removed in favor of including ``admin.site.urls``. - -* Authentication backends need to define the boolean attributes - ``supports_object_permissions`` and ``supports_anonymous_user`` until - version 1.4, at which point it will be assumed that all backends will - support these options. - 1.4 --- @@ -276,6 +262,15 @@ these changes. in 1.4. The backward compatibility will be removed -- ``HttpRequest.raw_post_data`` will no longer work. +1.7 +--- + +See the :doc:`Django 1.5 release notes` for more details on +these changes. + +* The function ``django.utils.itercompat.product`` will be removed. The Python + builtin version should be used instead. + 2.0 --- diff --git a/docs/intro/install.txt b/docs/intro/install.txt index 1efd182260..ef04eba572 100644 --- a/docs/intro/install.txt +++ b/docs/intro/install.txt @@ -10,7 +10,7 @@ Install Python -------------- Being a Python Web framework, Django requires Python. It works with any Python -version from 2.5 to 2.7 (due to backwards incompatibilities in Python 3.0, +version from 2.6 to 2.7 (due to backwards incompatibilities in Python 3.0, Django does not currently work with Python 3.0; see :doc:`the Django FAQ ` for more information on supported Python versions and the 3.0 transition), these versions of Python include a lightweight database called @@ -31,15 +31,15 @@ probably already have it installed. You can verify that Python is installed by typing ``python`` from your shell; you should see something like:: - Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) - [GCC 4.0.1 (Apple Inc. build 5465)] on darwin + Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) + [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> Set up a database ----------------- -If you installed Python 2.5 or later, you can skip this step for now. +If you installed Python 2.6 or later, you can skip this step for now. If not, or if you'd like to work with a "large" database engine like PostgreSQL, MySQL, or Oracle, consult the :ref:`database installation information diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt index d37564055e..7575afd454 100644 --- a/docs/intro/tutorial01.txt +++ b/docs/intro/tutorial01.txt @@ -221,9 +221,8 @@ your database connection settings. If you're new to databases, we recommend simply using SQLite by setting :setting:`ENGINE` to ``'django.db.backends.sqlite3'`` and :setting:`NAME` to -the place where you'd like to store the database. SQLite is included as part -of Python 2.5 and later, so you won't need to install anything else to support -your database. +the place where you'd like to store the database. SQLite is included in Python, +so you won't need to install anything else to support your database. .. note:: diff --git a/docs/ref/contrib/gis/deployment.txt b/docs/ref/contrib/gis/deployment.txt index 4cea022815..c50a3782dc 100644 --- a/docs/ref/contrib/gis/deployment.txt +++ b/docs/ref/contrib/gis/deployment.txt @@ -37,8 +37,8 @@ Example:: WSGIProcessGroup geodjango WSGIScriptAlias / /home/geo/geodjango/world.wsgi - Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/" - + Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/" + Order allow,deny Options Indexes Allow from all @@ -77,7 +77,7 @@ Example:: PythonPath "['/var/www/apps'] + sys.path" - Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/" + Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/" SetHandler None diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index f0b485fc97..59a0c36ad6 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -461,17 +461,6 @@ SQLite 3.3.6 was released in April 2006, so most current binary distributions for different platforms include newer version of SQLite usable from Python through either the ``pysqlite2`` or the ``sqlite3`` modules. -However, some platform/Python version combinations include older versions of -SQLite (e.g. the official binary distribution of Python 2.5 for Windows, 2.5.4 -as of this writing, includes SQLite 3.3.4). There are (as of Django 1.1) even -some tests in the Django test suite that will fail when run under this setup. - -As described :ref:`below`, this can be solved -by downloading and installing a newer version of ``pysqlite2`` -(``pysqlite-2.x.x.win32-py2.5.exe`` in the described case) that includes and -uses a newer version of SQLite. Python 2.6 for Windows ships with a version of -SQLite that is not affected by these issues. - Version 3.5.9 ------------- diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt index c8887c2779..84459f9021 100644 --- a/docs/releases/1.5.txt +++ b/docs/releases/1.5.txt @@ -39,3 +39,8 @@ Backwards incompatible changes in 1.5 Features deprecated in 1.5 ========================== +itercompat.product +~~~~~~~~~~~~~~~~~~ + +The :func:`~django.utils.itercompat.product` function has been deprecated. Use +the builtin `itertools.product` instead. diff --git a/docs/topics/db/transactions.txt b/docs/topics/db/transactions.txt index 0f0b52aa1e..589ebc7b5e 100644 --- a/docs/topics/db/transactions.txt +++ b/docs/topics/db/transactions.txt @@ -93,9 +93,7 @@ These functions, described in detail below, can be used in two different ways: # this code executes inside a transaction # ... -Both techniques work with all supported version of Python. However, in Python -2.5, you must add ``from __future__ import with_statement`` at the beginning -of your module if you are using the ``with`` statement. +Both techniques work with all supported version of Python. .. _decorator: http://docs.python.org/glossary.html#term-decorator .. _context manager: http://docs.python.org/glossary.html#term-context-manager diff --git a/docs/topics/install.txt b/docs/topics/install.txt index e91c3e0457..728ea05add 100644 --- a/docs/topics/install.txt +++ b/docs/topics/install.txt @@ -9,7 +9,7 @@ Install Python Being a Python Web framework, Django requires Python. -It works with any Python version from 2.5 to 2.7 (due to backwards +It works with any Python version from 2.6 to 2.7 (due to backwards incompatibilities in Python 3.0, Django does not currently work with Python 3.0; see :doc:`the Django FAQ ` for more information on supported Python versions and the 3.0 transition). diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index 39f07708ff..ad798dea2c 100644 --- a/docs/topics/testing.txt +++ b/docs/topics/testing.txt @@ -1591,10 +1591,6 @@ your test suite. You can use this as a context manager, like this:: - # This is necessary in Python 2.5 to enable the with statement. - # In 2.6 and up, it's not necessary. - from __future__ import with_statement - with self.assertTemplateUsed('index.html'): render_to_string('index.html') with self.assertTemplateUsed(template_name='index.html'): @@ -1656,12 +1652,7 @@ your test suite. self.assertNumQueries(7, lambda: my_function(using=7)) - If you're using Python 2.5 or greater you can also use this as a context - manager:: - - # This is necessary in Python 2.5 to enable the with statement, in 2.6 - # and up it is no longer necessary. - from __future__ import with_statement + You can also use this as a context manager:: with self.assertNumQueries(2): Person.objects.create(name="Aaron") diff --git a/setup.py b/setup.py index 1f14245acb..a19f660a5a 100644 --- a/setup.py +++ b/setup.py @@ -88,7 +88,6 @@ setup( 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.5', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Topic :: Internet :: WWW/HTTP', diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py index ce15b8b708..2499b7a350 100644 --- a/tests/regressiontests/forms/tests/widgets.py +++ b/tests/regressiontests/forms/tests/widgets.py @@ -25,8 +25,6 @@ class FormsWidgetTestCase(TestCase): self.assertHTMLEqual(w.render('email', 'some "quoted" & ampersanded value'), u'') self.assertHTMLEqual(w.render('email', 'test@example.com', attrs={'class': 'fun'}), u'') - # Note that doctest in Python 2.4 (and maybe 2.5?) doesn't support non-ascii - # characters in output, so we're displaying the repr() here. self.assertHTMLEqual(w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}), u'') # You can also pass 'attrs' to the constructor: