Ticket #17965: stuff_2.diff

File stuff_2.diff, 18.5 KB (added by Claude Paroz, 13 years ago)

Deprecate itercompat.product and more doc fixes

  • django/contrib/sessions/tests.py

    diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
    index 89bcce8..dbcaea2 100644
    a b class SessionMiddlewareTests(unittest.TestCase):  
    407407
    408408        # Handle the response through the middleware
    409409        response = middleware.process_response(request, response)
    410         # If it isn't in the cookie, that's fine (Python 2.5)
    411         if 'httponly' in settings.SESSION_COOKIE_NAME:
    412             self.assertFalse(
    413                response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
     410        self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
    414411
    415412        self.assertNotIn('httponly',
    416413                         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:  
    2525    # The mod_python version is more efficient, so try importing it first.
    2626    from mod_python.util import parse_qsl
    2727except 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
    3429
    3530__all__ = [
    3631    '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 3e5b758..2f1775e 100644
    a b from django.core.management.color import no_style  
    1212from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS,
    1313      IntegrityError, DatabaseError)
    1414from django.db.models import get_apps
    15 from django.utils.itercompat import product
     15from itertools import product
    1616
    1717try:
    1818    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:  
    1818    # The mod_python version is more efficient, so try importing it first.
    1919    from mod_python.util import parse_qsl
    2020except 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
    2722
    2823import 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._reserved
    3224# Some versions of Python 2.7 and later won't need this encoding bug fix:
    3325_cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"')
    3426# See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256
    try:  
    3931except Cookie.CookieError:
    4032    _cookie_allows_colon_in_names = False
    4133
    42 if _morsel_supports_httponly and _cookie_encodes_correctly and _cookie_allows_colon_in_names:
     34if _cookie_encodes_correctly and _cookie_allows_colon_in_names:
    4335    SimpleCookie = Cookie.SimpleCookie
    4436else:
    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
    6438
    6539    class SimpleCookie(Cookie.SimpleCookie):
    6640        if not _cookie_encodes_correctly:
    else:  
    8862
    8963                return val, encoded
    9064
    91         if not _cookie_allows_colon_in_names or not _morsel_supports_httponly:
     65        if not _cookie_allows_colon_in_names:
    9266            def load(self, rawdata):
    9367                self.bad_cookies = set()
    9468                super(SimpleCookie, self).load(rawdata)
  • django/utils/itercompat.py

    diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py
    index 82434b7..bc6f0fa 100644
    a b these implementations if necessary.  
    55"""
    66
    77import __builtin__
    8 import itertools
    98import warnings
    109
    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
    27 
    2810def is_iterable(x):
    2911    "A implementation independent way of checking for iterables"
    3012    try:
    def is_iterable(x):  
    3416    else:
    3517        return True
    3618
     19def product(*args, **kwds):
     20    # PendingDeprecationWarning in 1.5, remove this comment when the Deprecations
     21    # will have been advanced for 1.5
     22    warnings.warn("django.utils.itercompat.product is deprecated; use the native version instead",
     23                  PendingDeprecationWarning)
     24    return __builtin__.product(*args, **kwds)
     25
    3726def all(iterable):
    3827    warnings.warn("django.utils.itercompat.all is deprecated; use the native version instead",
    3928                  PendingDeprecationWarning)
  • docs/faq/install.txt

    diff --git a/docs/faq/install.txt b/docs/faq/install.txt
    index c5847d3..8021229 100644
    a b How do I get started?  
    1616What are Django's prerequisites?
    1717--------------------------------
    1818
    19 Django requires Python_, specifically any version of Python from 2.5
     19Django requires Python_, specifically any version of Python from 2.6
    2020through 2.7. No other Python libraries are required for basic Django
    2121usage.
    2222
    PostgreSQL fans, and MySQL_, `SQLite 3`_, and Oracle_ are also supported.  
    3939.. _`SQLite 3`: http://www.sqlite.org/
    4040.. _Oracle: http://www.oracle.com/
    4141
    42 Do I lose anything by using Python 2.5 versus newer Python versions, such as Python 2.6 or 2.7?
    43 -----------------------------------------------------------------------------------------------
     42Do I lose anything by using Python 2.6 versus newer Python versions, such as Python 2.7?
     43----------------------------------------------------------------------------------------
    4444
    4545Not in the core framework. Currently, Django itself officially supports any
    46 version of Python from 2.5 through 2.7, inclusive. However, newer versions of
     46version of Python from 2.6 through 2.7, inclusive. However, newer versions of
    4747Python are often faster, have more features, and are better supported. If you
    4848use a newer version of Python you will also have access to some APIs that
    49 aren't available under older versions of Python. For example, since Python 2.6,
    50 you can use the advanced string formatting described in :pep:`3101`.
     49aren't available under older versions of Python.
    5150
    5251Third-party applications for use with Django are, of course, free to set their
    5352own version requirements.
    versions as part of a migration which will end with Django running on Python 3  
    5857
    5958All else being equal, we recommend that you use the latest 2.x release
    6059(currently Python 2.7). This will let you take advantage of the numerous
    61 improvements and optimizations to the Python language since version 2.5, and
     60improvements and optimizations to the Python language since version 2.6, and
    6261will help ease the process of dropping support for older Python versions on
    6362the road to Python 3.
    6463
  • docs/howto/jython.txt

    diff --git a/docs/howto/jython.txt b/docs/howto/jython.txt
    index 68f8378..5b11a88 100644
    a b Running Django on Jython  
    44
    55.. index:: Jython, Java, JVM
    66
     7.. admonition::
     8
     9    Django 1.5 has dropped support for Python 2.5. Until Jython provides a new
     10    version that supports 2.6, Django 1.5 is no more compatible with Jython.
     11    Please use Django 1.4 if you want to use Django over Jython.
     12
    713Jython_ is an implementation of Python that runs on the Java platform (JVM).
    814Django runs cleanly on Jython version 2.5 or later, which means you can deploy
    915Django on any Java platform.
  • docs/internals/deprecation.txt

    diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
    index 81ca7af..66791e6 100644
    a b in a backward incompatible way, following their deprecation, as per the  
    77:ref:`deprecation policy <internal-release-deprecation-policy>`. More details
    88about each item can often be found in the release notes of two versions prior.
    99
    10 1.3
    11 ---
    12 
    13 See the :doc:`Django 1.1 release notes</releases/1.1>` for more details on
    14 these changes.
    15 
    16 * ``AdminSite.root()``.  This method of hooking up the admin URLs will be
    17   removed in favor of including ``admin.site.urls``.
    18 
    19 * Authentication backends need to define the boolean attributes
    20   ``supports_object_permissions`` and ``supports_anonymous_user`` until
    21   version 1.4, at which point it will be assumed that all backends will
    22   support these options.
    23 
    24101.4
    2511---
    2612
    these changes.  
    276262  in 1.4. The backward compatibility will be removed --
    277263  ``HttpRequest.raw_post_data`` will no longer work.
    278264
     2651.7
     266---
     267
     268See the :doc:`Django 1.5 release notes</releases/1.5>` for more details on
     269these changes.
     270
     271* The function ``django.utils.itercompat.product`` will be removed. The Python
     272  builtin version should be used instead.
     273
    2792742.0
    280275---
    281276
  • docs/intro/install.txt

    diff --git a/docs/intro/install.txt b/docs/intro/install.txt
    index 1efd182..ef04eba 100644
    a b Install Python  
    1010--------------
    1111
    1212Being a Python Web framework, Django requires Python. It works with any Python
    13 version from 2.5 to 2.7 (due to backwards incompatibilities in Python 3.0,
     13version from 2.6 to 2.7 (due to backwards incompatibilities in Python 3.0,
    1414Django does not currently work with Python 3.0; see :doc:`the Django FAQ
    1515</faq/install>` for more information on supported Python versions and the 3.0
    1616transition), these versions of Python include a lightweight database called
    probably already have it installed.  
    3131You can verify that Python is installed by typing ``python`` from your shell;
    3232you should see something like::
    3333
    34     Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
    35     [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
     34    Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
     35    [GCC 4.4.5] on linux2
    3636    Type "help", "copyright", "credits" or "license" for more information.
    3737    >>>
    3838
    3939Set up a database
    4040-----------------
    4141
    42 If you installed Python 2.5 or later, you can skip this step for now.
     42If you installed Python 2.6 or later, you can skip this step for now.
    4343
    4444If not, or if you'd like to work with a "large" database engine like PostgreSQL,
    4545MySQL, or Oracle, consult the :ref:`database installation information
  • docs/intro/tutorial01.txt

    diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt
    index d375640..7575afd 100644
    a b your database connection settings.  
    221221
    222222If you're new to databases, we recommend simply using SQLite by setting
    223223:setting:`ENGINE` to ``'django.db.backends.sqlite3'`` and :setting:`NAME` to
    224 the place where you'd like to store the database. SQLite is included as part
    225 of Python 2.5 and later, so you won't need to install anything else to support
    226 your database.
     224the place where you'd like to store the database. SQLite is included in Python,
     225so you won't need to install anything else to support your database.
    227226
    228227.. note::
    229228
  • docs/ref/contrib/gis/deployment.txt

    diff --git a/docs/ref/contrib/gis/deployment.txt b/docs/ref/contrib/gis/deployment.txt
    index 4cea022..c50a378 100644
    a b Example::  
    3737      WSGIProcessGroup geodjango
    3838      WSGIScriptAlias / /home/geo/geodjango/world.wsgi
    3939
    40       Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/"
    41       <Directory "/usr/lib/python2.5/site-packages/django/contrib/admin/media/">
     40      Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/"
     41      <Directory "/usr/lib/python2.6/site-packages/django/contrib/admin/media/">
    4242        Order allow,deny
    4343        Options Indexes
    4444        Allow from all
    Example::  
    7777        PythonPath "['/var/www/apps'] + sys.path"
    7878      </Location>
    7979
    80       Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/"
     80      Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/"
    8181      <Location "/media">
    8282        SetHandler None
    8383      </Location>
  • docs/ref/databases.txt

    diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
    index f0b485f..59a0c36 100644
    a b SQLite 3.3.6 was released in April 2006, so most current binary distributions  
    461461for different platforms include newer version of SQLite usable from Python
    462462through either the ``pysqlite2`` or the ``sqlite3`` modules.
    463463
    464 However, some platform/Python version combinations include older versions of
    465 SQLite (e.g. the official binary distribution of Python 2.5 for Windows, 2.5.4
    466 as of this writing, includes SQLite 3.3.4). There are (as of Django 1.1) even
    467 some tests in the Django test suite that will fail when run under this setup.
    468 
    469 As described :ref:`below<using-newer-versions-of-pysqlite>`, this can be solved
    470 by downloading and installing a newer version of ``pysqlite2``
    471 (``pysqlite-2.x.x.win32-py2.5.exe`` in the described case) that includes and
    472 uses a newer version of SQLite. Python 2.6 for Windows ships with a version of
    473 SQLite that is not affected by these issues.
    474 
    475464Version 3.5.9
    476465-------------
    477466
  • docs/releases/1.5.txt

    diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
    index c8887c2..84459f9 100644
    a b Backwards incompatible changes in 1.5  
    3939Features deprecated in 1.5
    4040==========================
    4141
     42itercompat.product
     43~~~~~~~~~~~~~~~~~~
     44
     45The :func:`~django.utils.itercompat.product` function has been deprecated. Use
     46the builtin `itertools.product` instead.
  • docs/topics/db/transactions.txt

    diff --git a/docs/topics/db/transactions.txt b/docs/topics/db/transactions.txt
    index 0f0b52a..589ebc7 100644
    a b These functions, described in detail below, can be used in two different ways:  
    9393            # this code executes inside a transaction
    9494            # ...
    9595
    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.
     96Both techniques work with all supported version of Python.
    9997
    10098.. _decorator: http://docs.python.org/glossary.html#term-decorator
    10199.. _context manager: http://docs.python.org/glossary.html#term-context-manager
  • docs/topics/install.txt

    diff --git a/docs/topics/install.txt b/docs/topics/install.txt
    index e91c3e0..728ea05 100644
    a b Install Python  
    99
    1010Being a Python Web framework, Django requires Python.
    1111
    12 It works with any Python version from 2.5 to 2.7 (due to backwards
     12It works with any Python version from 2.6 to 2.7 (due to backwards
    1313incompatibilities in Python 3.0, Django does not currently work with
    1414Python 3.0; see :doc:`the Django FAQ </faq/install>` for more
    1515information on supported Python versions and the 3.0 transition).
  • docs/topics/testing.txt

    diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
    index 39f0770..ad798de 100644
    a b your test suite.  
    15911591
    15921592    You can use this as a context manager, like this::
    15931593
    1594         # This is necessary in Python 2.5 to enable the with statement.
    1595         # In 2.6 and up, it's not necessary.
    1596         from __future__ import with_statement
    1597 
    15981594        with self.assertTemplateUsed('index.html'):
    15991595            render_to_string('index.html')
    16001596        with self.assertTemplateUsed(template_name='index.html'):
    your test suite.  
    16561652
    16571653        self.assertNumQueries(7, lambda: my_function(using=7))
    16581654
    1659     If you're using Python 2.5 or greater you can also use this as a context
    1660     manager::
    1661 
    1662         # This is necessary in Python 2.5 to enable the with statement, in 2.6
    1663         # and up it is no longer necessary.
    1664         from __future__ import with_statement
     1655    You can also use this as a context manager::
    16651656
    16661657        with self.assertNumQueries(2):
    16671658            Person.objects.create(name="Aaron")
  • setup.py

    diff --git a/setup.py b/setup.py
    index 1f14245..a19f660 100644
    a b setup(  
    8888        'License :: OSI Approved :: BSD License',
    8989        'Operating System :: OS Independent',
    9090        'Programming Language :: Python',
    91         'Programming Language :: Python :: 2.5',
    9291        'Programming Language :: Python :: 2.6',
    9392        'Programming Language :: Python :: 2.7',
    9493        'Topic :: Internet :: WWW/HTTP',
  • tests/regressiontests/forms/tests/widgets.py

    diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py
    index ce15b8b..2499b7a 100644
    a b class FormsWidgetTestCase(TestCase):  
    2525        self.assertHTMLEqual(w.render('email', 'some "quoted" & ampersanded value'), u'<input type="text" name="email" value="some &quot;quoted&quot; &amp; ampersanded value" />')
    2626        self.assertHTMLEqual(w.render('email', 'test@example.com', attrs={'class': 'fun'}), u'<input type="text" name="email" value="test@example.com" class="fun" />')
    2727
    28         # Note that doctest in Python 2.4 (and maybe 2.5?) doesn't support non-ascii
    29         # characters in output, so we're displaying the repr() here.
    3028        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" />')
    3129
    3230        # You can also pass 'attrs' to the constructor:
Back to Top