Ticket #17965: stuff.diff

File stuff.diff, 7.7 KB (added by Jonas H., 13 years ago)
  • django/contrib/sessions/tests.py

    commit facbc7981d9668312b189a21d94a4c60dd1d4342
    Author: Jonas Haag <jonas@lophus.org>
    Date:   Fri Mar 23 18:51:06 2012 +0100
    
        stuff.patch
    
    diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
    index 4d2fefe..0368ca2 100644
    a b class SessionMiddlewareTests(unittest.TestCase):  
    404404
    405405        # Handle the response through the middleware
    406406        response = middleware.process_response(request, response)
    407         # If it isn't in the cookie, that's fine (Python 2.5)
    408         if 'httponly' in settings.SESSION_COOKIE_NAME:
    409             self.assertFalse(
    410                response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
     407        self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
    411408
    412409        self.assertNotIn('httponly',
    413410                         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 176ccef..2f1775e 100644
    a b  
    1 # This is necessary in Python 2.5 to enable the with statement, in 2.6
    2 # and up it is no longer necessary.
    3 
    41import sys
    52import os
    63import gzip
    from django.core.management.color import no_style  
    1512from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS,
    1613      IntegrityError, DatabaseError)
    1714from django.db.models import get_apps
    18 from django.utils.itercompat import product
     15from itertools import product
    1916
    2017try:
    2118    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/http.py

    diff --git a/django/utils/http.py b/django/utils/http.py
    index d343a37..dbd18d8 100644
    a b def quote_etag(etag):  
    207207    """
    208208    return '"%s"' % etag.replace('\\', '\\\\').replace('"', '\\"')
    209209
    210 if sys.version_info >= (2, 6):
    211     def same_origin(url1, url2):
    212         """
    213         Checks if two URLs are 'same-origin'
    214         """
    215         p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
    216         return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)
    217 else:
    218     # Python 2.5 compatibility. This actually works for Python 2.6 and above,
    219     # but the above definition is much more obviously correct and so is
    220     # preferred going forward.
    221     def same_origin(url1, url2):
    222         """
    223         Checks if two URLs are 'same-origin'
    224         """
    225         p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
    226         return p1[0:2] == p2[0:2]
     210def same_origin(url1, url2):
     211    """
     212    Checks if two URLs are 'same-origin'
     213    """
     214    p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2)
     215    return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)
  • django/utils/itercompat.py

    diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py
    index 82434b7..83a8bec 100644
    a b these implementations if necessary.  
    77import __builtin__
    88import itertools
    99import warnings
    10 
    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
     10from itertools import product
    2711
    2812def is_iterable(x):
    2913    "A implementation independent way of checking for iterables"
  • 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/modeltests/serializers/tests.py

    diff --git a/tests/modeltests/serializers/tests.py b/tests/modeltests/serializers/tests.py
    index d474937..02538b0 100644
    a b  
    1 # This is necessary in Python 2.5 to enable the with statement, in 2.6
    2 # and up it is no longer necessary.
    31from __future__ import absolute_import
    42
    53# -*- coding: utf-8 -*-
Back to Top