Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16155 -- Removed Python 2.4 compatibility constructs from code…

… and mentions from docs. Thanks Aymeric Augustin for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16349 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit dff31de20aac85e4f4834c2466762cbf23fc0a7b 1 parent da0c7cd
Ramiro Morales authored
5  INSTALL
... ...
@@ -1,6 +1,6 @@
1 1
 Thanks for downloading Django.
2 2
 
3  
-To install it, make sure you have Python 2.4 or greater installed. Then run
  3
+To install it, make sure you have Python 2.5 or greater installed. Then run
4 4
 this command from the command prompt:
5 5
 
6 6
     python setup.py install
@@ -9,8 +9,9 @@ AS AN ALTERNATIVE, you can just copy the entire "django" directory to Python's
9 9
 site-packages directory, which is located wherever your Python installation
10 10
 lives. Some places you might check are:
11 11
 
  12
+    /usr/lib/python2.7/site-packages (Unix, Python 2.7)
  13
+    /usr/lib/python2.6/site-packages (Unix, Python 2.6)
12 14
     /usr/lib/python2.5/site-packages (Unix, Python 2.5)
13  
-    /usr/lib/python2.4/site-packages (Unix, Python 2.4)
14 15
     C:\\PYTHON\site-packages         (Windows)
15 16
 
16 17
 For more detailed instructions, see docs/intro/install.txt.
3  django/core/cache/__init__.py
@@ -29,8 +29,7 @@
29 29
         # Python 2.6 and greater
30 30
         from urlparse import parse_qsl
31 31
     except ImportError:
32  
-        # Python 2.5, 2.4.  Works on Python 2.6 but raises
33  
-        # PendingDeprecationWarning
  32
+        # Python 2.5.  Works on Python 2.6 but raises PendingDeprecationWarning
34 33
         from cgi import parse_qsl
35 34
 
36 35
 __all__ = [
6  django/db/backends/oracle/base.py
@@ -176,12 +176,6 @@ def convert_values(self, value, field):
176 176
         # classes to normalize values from the database (the to_python
177 177
         # method is used for validation and isn't what we want here).
178 178
         elif isinstance(value, Database.Timestamp):
179  
-            # In Python 2.3, the cx_Oracle driver returns its own
180  
-            # Timestamp object that we must convert to a datetime class.
181  
-            if not isinstance(value, datetime.datetime):
182  
-                value = datetime.datetime(value.year, value.month,
183  
-                        value.day, value.hour, value.minute, value.second,
184  
-                        value.fsecond)
185 179
             if field and field.get_internal_type() == 'DateTimeField':
186 180
                 pass
187 181
             elif field and field.get_internal_type() == 'DateField':
9  django/db/models/base.py
@@ -915,10 +915,5 @@ def model_unpickle(model, attrs, factory):
915 915
     return cls.__new__(cls)
916 916
 model_unpickle.__safe_for_unpickle__ = True
917 917
 
918  
-if sys.version_info < (2, 5):
919  
-    # Prior to Python 2.5, Exception was an old-style class
920  
-    def subclass_exception(name, parents, unused):
921  
-        return types.ClassType(name, parents, {})
922  
-else:
923  
-    def subclass_exception(name, parents, module):
924  
-        return type(name, parents, {'__module__': module})
  918
+def subclass_exception(name, parents, module):
  919
+    return type(name, parents, {'__module__': module})
5  django/http/__init__.py
@@ -17,13 +17,12 @@
17 17
         # Python 2.6 and greater
18 18
         from urlparse import parse_qsl
19 19
     except ImportError:
20  
-        # Python 2.5, 2.4.  Works on Python 2.6 but raises
21  
-        # PendingDeprecationWarning
  20
+        # Python 2.5.  Works on Python 2.6 but raises PendingDeprecationWarning
22 21
         from cgi import parse_qsl
23 22
 
24 23
 import Cookie
25 24
 # httponly support exists in Python 2.6's Cookie library,
26  
-# but not in Python 2.4 or 2.5.
  25
+# but not in Python 2.5.
27 26
 _morsel_supports_httponly = Cookie.Morsel._reserved.has_key('httponly')
28 27
 # Some versions of Python 2.7 and later won't need this encoding bug fix:
29 28
 _cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"')
21  django/utils/hashcompat.py
@@ -3,22 +3,13 @@
3 3
 hashlib module containing both hash algorithms. Here, we provide a common
4 4
 interface to the md5 and sha constructors, depending on system version.
5 5
 """
6  
-import sys
7  
-import warnings
8 6
 
  7
+import warnings
9 8
 warnings.warn("django.utils.hashcompat is deprecated; use hashlib instead",
10 9
               PendingDeprecationWarning)
11 10
 
12  
-if sys.version_info >= (2, 5):
13  
-    import hashlib
14  
-    md5_constructor = hashlib.md5
15  
-    md5_hmac = md5_constructor
16  
-    sha_constructor = hashlib.sha1
17  
-    sha_hmac = sha_constructor
18  
-else:
19  
-    import md5
20  
-    md5_constructor = md5.new
21  
-    md5_hmac = md5
22  
-    import sha
23  
-    sha_constructor = sha.new
24  
-    sha_hmac = sha
  11
+import hashlib
  12
+md5_constructor = hashlib.md5
  13
+md5_hmac = md5_constructor
  14
+sha_constructor = hashlib.sha1
  15
+sha_hmac = sha_constructor
4  django/utils/http.py
@@ -198,8 +198,8 @@ def same_origin(url1, url2):
198 198
         p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
199 199
         return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)
200 200
 else:
201  
-    # Python 2.4, 2.5 compatibility. This actually works for Python 2.6 and
202  
-    # above, but the above definition is much more obviously correct and so is
  201
+    # Python 2.5 compatibility. This actually works for Python 2.6 and above,
  202
+    # but the above definition is much more obviously correct and so is
203 203
     # preferred going forward.
204 204
     def same_origin(url1, url2):
205 205
         """
2  django/utils/itercompat.py
@@ -7,7 +7,7 @@
7 7
 import itertools
8 8
 import warnings
9 9
 
10  
-# Fallback for Python 2.4, Python 2.5
  10
+# Fallback for Python 2.5
11 11
 def product(*args, **kwds):
12 12
     """
13 13
     Taken from http://docs.python.org/library/itertools.html#itertools.product
3  django/utils/translation/trans_real.py
@@ -63,8 +63,7 @@ def to_language(locale):
63 63
 class DjangoTranslation(gettext_module.GNUTranslations):
64 64
     """
65 65
     This class sets up the GNUTranslations context with regard to output
66  
-    charset. Django uses a defined DEFAULT_CHARSET as the output charset on
67  
-    Python 2.4.
  66
+    charset.
68 67
     """
69 68
     def __init__(self, *args, **kw):
70 69
         gettext_module.GNUTranslations.__init__(self, *args, **kw)
16  docs/faq/install.txt
@@ -16,7 +16,7 @@ How do I get started?
16 16
 What are Django's prerequisites?
17 17
 --------------------------------
18 18
 
19  
-Django requires Python_, specifically any version of Python from 2.4
  19
+Django requires Python_, specifically any version of Python from 2.5
20 20
 through 2.7. No other Python libraries are required for basic Django
21 21
 usage.
22 22
 
@@ -40,17 +40,15 @@ PostgreSQL fans, and MySQL_, `SQLite 3`_, and Oracle_ are also supported.
40 40
 .. _`SQLite 3`: http://www.sqlite.org/
41 41
 .. _Oracle: http://www.oracle.com/
42 42
 
43  
-Do I lose anything by using Python 2.4 versus newer Python versions, such as Python 2.5 or 2.6?
  43
+Do I lose anything by using Python 2.5 versus newer Python versions, such as Python 2.6 or 2.7?
44 44
 -----------------------------------------------------------------------------------------------
45 45
 
46 46
 Not in the core framework. Currently, Django itself officially supports any
47  
-version of Python from 2.4 through 2.7, inclusive. However, newer versions of
  47
+version of Python from 2.5 through 2.7, inclusive. However, newer versions of
48 48
 Python are often faster, have more features, and are better supported. If you
49 49
 use a newer version of Python you will also have access to some APIs that
50  
-aren't available under older versions of Python. For example Django provides
51  
-some `context managers`_ for various operations. If you use Python 2.4 you
52  
-won't be able to use them, however other APIs which provide the same
53  
-functionality are always made available.
  50
+aren't available under older versions of Python. For example, since Python 2.6,
  51
+you can use the advanced string formatting described in `PEP 3101`_.
54 52
 
55 53
 Third-party applications for use with Django are, of course, free to set their
56 54
 own version requirements.
@@ -61,11 +59,11 @@ versions as part of a migration which will end with Django running on Python 3
61 59
 
62 60
 All else being equal, we recommend that you use the latest 2.x release
63 61
 (currently Python 2.7). This will let you take advantage of the numerous
64  
-improvements and optimizations to the Python language since version 2.4, and
  62
+improvements and optimizations to the Python language since version 2.5, and
65 63
 will help ease the process of dropping support for older Python versions on
66 64
 the road to Python 3.
67 65
 
68  
-.. _context managers: http://docs.python.org/reference/datamodel.html#context-managers
  66
+.. _PEP 3101: http://www.python.org/dev/peps/pep-3101/
69 67
 
70 68
 Can I use Django with Python 2.4?
71 69
 ---------------------------------
11  docs/internals/contributing/writing-code/branch-policy.txt
@@ -135,8 +135,8 @@ Pointing Python at the new Django version
135 135
 Once you've retrieved the branch's code, you'll need to change your Python
136 136
 ``site-packages`` directory so that it points to the branch version of the
137 137
 ``django`` directory. (The ``site-packages`` directory is somewhere such as
138  
-``/usr/lib/python2.4/site-packages`` or
139  
-``/usr/local/lib/python2.4/site-packages`` or ``C:\Python\site-packages``.)
  138
+``/usr/lib/python2.7/site-packages`` or
  139
+``/usr/local/lib/python2.7/site-packages`` or ``C:\Python\site-packages``.)
140 140
 
141 141
 The simplest way to do this is by renaming the old ``django`` directory to
142 142
 ``django.OLD`` and moving the trunk version of the code into the directory
@@ -169,12 +169,5 @@ sure all other lines are commented::
169 169
     # On windows a path may look like this:
170 170
     # C:/path/to/<branch>
171 171
 
172  
-If you're using Django 0.95 or earlier and installed it using
173  
-``python setup.py install``, you'll have a directory called something like
174  
-``Django-0.95-py2.4.egg`` instead of ``django``. In this case, edit the file
175  
-``setuptools.pth`` and remove the line that references the Django ``.egg``
176  
-file. Then copy the branch's version of the ``django`` directory into
177  
-``site-packages``.
178  
-
179 172
 .. _path file: http://docs.python.org/library/site.html
180 173
 .. _django-developers: http://groups.google.com/group/django-developers
12  docs/intro/install.txt
@@ -10,13 +10,11 @@ Install Python
10 10
 --------------
11 11
 
12 12
 Being a Python Web framework, Django requires Python. It works with any Python
13  
-version from 2.4 to 2.7 (due to backwards
14  
-incompatibilities in Python 3.0, Django does not currently work with
15  
-Python 3.0; see :doc:`the Django FAQ </faq/install>` for more
16  
-information on supported Python versions and the 3.0 transition), but we
17  
-recommend installing Python 2.5 or later. If you do so, you won't need to set
18  
-up a database just yet: Python 2.5 or later includes a lightweight database
19  
-called SQLite_.
  13
+version from 2.5 to 2.7 (due to backwards incompatibilities in Python 3.0,
  14
+Django does not currently work with Python 3.0; see :doc:`the Django FAQ
  15
+</faq/install>` for more information on supported Python versions and the 3.0
  16
+transition), these versions of Python include a lightweight database called
  17
+SQLite_ so you won't need to set up a database just yet.
20 18
 
21 19
 .. _sqlite: http://sqlite.org/
22 20
 
25  docs/ref/contrib/gis/install.txt
@@ -8,7 +8,7 @@ Overview
8 8
 ========
9 9
 In general, GeoDjango installation requires:
10 10
 
11  
-1. :ref:`python24` and :ref:`django`
  11
+1. Python and :ref:`django`
12 12
 2. :ref:`spatial_database`
13 13
 3. :ref:`geospatial_libs`
14 14
 
@@ -32,22 +32,10 @@ instructions are available for:
32 32
 Requirements
33 33
 ============
34 34
 
35  
-.. _python24:
36  
-
37  
-Python 2.4+
38  
------------
39  
-
40  
-Python 2.4 is the minimum version supported by Django, however Python 2.5+ is
41  
-recommended because the `ctypes`__ module comes included; otherwise, 2.4 users
42  
-will need to `download and install ctypes`__.
43  
-
44  
-__ http://docs.python.org/lib/module-ctypes.html
45  
-__ http://sourceforge.net/projects/ctypes/files/
46  
-
47 35
 .. _django:
48 36
 
49  
-Django
50  
-------
  37
+Python and Django
  38
+-----------------
51 39
 
52 40
 Because GeoDjango is included with Django, please refer to Django's
53 41
 :doc:`installation instructions </intro/install>` for details on how to install.
@@ -1034,7 +1022,6 @@ Required package information:
1034 1022
 * ``flex``: required to build PostGIS
1035 1023
 * ``postgresql-8.1``
1036 1024
 * ``postgresql-server-dev-8.1``: for ``pg_config``
1037  
-* ``python-ctypes``: Python 2.4 needs to have ctypes installed separately
1038 1025
 * ``python-psycopg2``
1039 1026
 * ``python-setuptools``: for ``easy_install``
1040 1027
 
@@ -1110,7 +1097,7 @@ Python
1110 1097
 ^^^^^^
1111 1098
 
1112 1099
 First, download the latest `Python 2.7 installer`__ from the Python Web site.
1113  
-Next, run the installer and keep the defaults -- for example, keep 
  1100
+Next, run the installer and keep the defaults -- for example, keep
1114 1101
 'Install for all users' checked and the installation path set as
1115 1102
 ``C:\Python27``.
1116 1103
 
@@ -1165,7 +1152,7 @@ tree and select :menuselection:`PostGIS 1.5 for PostgreSQL 9.0`.
1165 1152
 
1166 1153
 After clicking next, you will be prompted to select your mirror, PostGIS
1167 1154
 will be downloaded, and the PostGIS installer will begin.  Select only the
1168  
-default options during install (e.g., do not uncheck the option to create a 
  1155
+default options during install (e.g., do not uncheck the option to create a
1169 1156
 default PostGIS database).
1170 1157
 
1171 1158
 .. note::
@@ -1216,7 +1203,7 @@ executable with ``cmd.exe``, will set this up::
1216 1203
      reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROJ_LIB /t REG_EXPAND_SZ /f /d "%PROJ_LIB%"
1217 1204
 
1218 1205
 For your convenience, these commands are available in the execuatble batch
1219  
-script, :download:`geodjango_setup.bat`.  
  1206
+script, :download:`geodjango_setup.bat`.
1220 1207
 
1221 1208
 .. note::
1222 1209
 
20  docs/releases/1.4.txt
@@ -17,6 +17,26 @@ we've `begun the deprecation process for some features`_.
17 17
 .. _backwards incompatible changes: backwards-incompatible-changes-1.4_
18 18
 .. _begun the deprecation process for some features: deprecated-features-1.4_
19 19
 
  20
+Python compatibility
  21
+====================
  22
+
  23
+While not a new feature, it's important to note that Django 1.4 introduces the
  24
+second shift in our Python compatibility policy since Django's initial public
  25
+debut. Django 1.2 dropped support for Python 2.3; now Django 1.4 drops support
  26
+for Python 2.4. As such, the minimum Python version required for Django is now
  27
+2.5, and Django is tested and supported on Python 2.5, 2.6 and 2.7.
  28
+
  29
+This change should affect only a small number of Django users, as most
  30
+operating-system vendors today are shipping Python 2.5 or newer as their default
  31
+version. If you're still using Python 2.4, however, you'll need to stick to
  32
+Django 1.3 until you can upgrade; per :doc:`our support policy
  33
+</internals/release-process>`, Django 1.3 will continue to receive security
  34
+support until the release of Django 1.5.
  35
+
  36
+Django does not support Python 3.x at this time. A document outlining our full
  37
+timeline for deprecating Python 2.x and moving to Python 3.x will be published
  38
+before the release of Django 1.4.
  39
+
20 40
 What's new in Django 1.4
21 41
 ========================
22 42
 
8  docs/topics/db/transactions.txt
@@ -79,9 +79,6 @@ These functions, described in detail below, can be used in two different ways:
79 79
                 # this code executes inside a transaction
80 80
                 # ...
81 81
 
82  
-      This technique works with all supported version of Python (that is, with
83  
-      Python 2.4 and greater).
84  
-
85 82
     * As a `context manager`_ around a particular block of code::
86 83
 
87 84
             from django.db import transaction
@@ -96,8 +93,9 @@ These functions, described in detail below, can be used in two different ways:
96 93
                     # this code executes inside a transaction
97 94
                     # ...
98 95
 
99  
-      The ``with`` statement is new in Python 2.5, and so this syntax can only
100  
-      be used with Python 2.5 and above.
  96
+Both techniques work with all supported version of Python. However, in Python
  97
+2.5, you must add ``from __future__ import with_statement`` at the beginning
  98
+of your module if you are using the ``with`` statement.
101 99
 
102 100
 .. _decorator: http://docs.python.org/glossary.html#term-decorator
103 101
 .. _context manager: http://docs.python.org/glossary.html#term-context-manager
7  docs/topics/install.txt
@@ -9,7 +9,7 @@ Install Python
9 9
 
10 10
 Being a Python Web framework, Django requires Python.
11 11
 
12  
-It works with any Python version from 2.4 to 2.7 (due to backwards
  12
+It works with any Python version from 2.5 to 2.7 (due to backwards
13 13
 incompatibilities in Python 3.0, Django does not currently work with
14 14
 Python 3.0; see :doc:`the Django FAQ </faq/install>` for more
15 15
 information on supported Python versions and the 3.0 transition).
@@ -102,11 +102,6 @@ database bindings are installed.
102 102
   will also want to read the database-specific :ref:`notes for the MySQL
103 103
   backend <mysql-notes>`.
104 104
 
105  
-* If you're using SQLite and Python 2.4, you'll need pysqlite_. Use version
106  
-  2.0.3 or higher. Python 2.5 ships with an SQLite wrapper in the standard
107  
-  library, so you don't need to install anything extra in that case. Please
108  
-  read the :ref:`SQLite backend notes <sqlite-notes>`.
109  
-
110 105
 * If you're using Oracle, you'll need a copy of cx_Oracle_, but please
111 106
   read the database-specific :ref:`notes for the Oracle backend <oracle-notes>`
112 107
   for important information regarding supported versions of both Oracle and
8  docs/topics/logging.txt
@@ -441,10 +441,6 @@ Messages to this logger have the following extra context:
441 441
     * ``request``: The request object that generated the logging
442 442
       message.
443 443
 
444  
-.. note::
445  
-    Due to a limitation in the logging library, this extra
446  
-    context is not available if you are using Python 2.4.
447  
-
448 444
 ``django.db.backends``
449 445
 ~~~~~~~~~~~~~~~~~~~~~~
450 446
 
@@ -462,10 +458,6 @@ For performance reasons, SQL logging is only enabled when
462 458
 ``settings.DEBUG`` is set to ``True``, regardless of the logging
463 459
 level or handlers that are installed.
464 460
 
465  
-.. note::
466  
-    Due to a limitation in the logging library, this extra
467  
-    context is not available if you are using Python 2.4.
468  
-
469 461
 Handlers
470 462
 --------
471 463
 
2  docs/topics/testing.txt
@@ -79,7 +79,7 @@ module defines tests in class-based approach.
79 79
     adding some extremely useful features. To ensure that every Django
80 80
     project can benefit from these new features, Django ships with a
81 81
     copy of unittest2_, a copy of the Python 2.7 unittest library,
82  
-    backported for Python 2.4 compatibility.
  82
+    backported for Python 2.5 compatibility.
83 83
 
84 84
     To access this library, Django provides the
85 85
     ``django.utils.unittest`` module alias. If you are using Python
10  tests/regressiontests/admin_scripts/tests.py
@@ -1126,20 +1126,14 @@ def test_help(self):
1126 1126
         "--help is handled as a special case"
1127 1127
         args = ['--help']
1128 1128
         out, err = self.run_manage(args)
1129  
-        if sys.version_info < (2, 5):
1130  
-            self.assertOutput(out, "usage: manage.py subcommand [options] [args]")
1131  
-        else:
1132  
-            self.assertOutput(out, "Usage: manage.py subcommand [options] [args]")
  1129
+        self.assertOutput(out, "Usage: manage.py subcommand [options] [args]")
1133 1130
         self.assertOutput(out, "Type 'manage.py help <subcommand>' for help on a specific subcommand.")
1134 1131
 
1135 1132
     def test_short_help(self):
1136 1133
         "-h is handled as a short form of --help"
1137 1134
         args = ['-h']
1138 1135
         out, err = self.run_manage(args)
1139  
-        if sys.version_info < (2, 5):
1140  
-            self.assertOutput(out, "usage: manage.py subcommand [options] [args]")
1141  
-        else:
1142  
-            self.assertOutput(out, "Usage: manage.py subcommand [options] [args]")
  1136
+        self.assertOutput(out, "Usage: manage.py subcommand [options] [args]")
1143 1137
         self.assertOutput(out, "Type 'manage.py help <subcommand>' for help on a specific subcommand.")
1144 1138
 
1145 1139
     def test_specific_help(self):
3  tests/regressiontests/httpwrappers/tests.py
@@ -248,9 +248,6 @@ def test_encode(self):
248 248
         """
249 249
         Test that we don't output tricky characters in encoded value
250 250
         """
251  
-        # Python 2.4 compatibility note: Python 2.4's cookie implementation
252  
-        # always returns Set-Cookie headers terminating in semi-colons.
253  
-        # That's not the bug this test is looking for, so ignore it.
254 251
         c = SimpleCookie()
255 252
         c['test'] = "An,awkward;value"
256 253
         self.assertTrue(";" not in c.output().rstrip(';')) # IE compat

0 notes on commit dff31de

Please sign in to comment.
Something went wrong with that request. Please try again.