Ticket #12164: 12164.diff

File 12164.diff, 38.0 KB (added by Tim Graham, 15 years ago)
  • django/test/simple.py

     
    101101            raise ValueError("Test label '%s' does not refer to a test class" % label)
    102102        return TestClass(parts[2])
    103103
    104 # Python 2.3 compatibility: TestSuites were made iterable in 2.4.
    105 # We need to iterate over them, so we add the missing method when
    106 # necessary.
    107 try:
    108     getattr(unittest.TestSuite, '__iter__')
    109 except AttributeError:
    110     setattr(unittest.TestSuite, '__iter__', lambda s: iter(s._tests))
    111 
    112104def partition_suite(suite, classes, bins):
    113105    """
    114106    Partitions a test suite by test type.
  • django/db/models/options.py

     
    11import re
    22from bisect import bisect
    3 try:
    4     set
    5 except NameError:
    6     from sets import Set as set     # Python 2.3 fallback
    73
    84from django.conf import settings
    95from django.db.models.related import RelatedObject
  • django/db/models/fields/__init__.py

     
    33import os
    44import re
    55import time
    6 try:
    7     import decimal
    8 except ImportError:
    9     from django.utils import _decimal as decimal    # for Python 2.3
    106
    117from django.db import connection
    128from django.db.models import signals
  • django/db/models/fields/related.py

     
    1111from django.core import exceptions
    1212from django import forms
    1313
    14 try:
    15     set
    16 except NameError:
    17     from sets import Set as set   # Python 2.3 fallback
    18 
    1914RECURSIVE_RELATIONSHIP_CONSTANT = 'self'
    2015
    2116pending_lookups = {}
  • django/db/models/query_utils.py

     
    1212from django.utils import tree
    1313from django.utils.datastructures import SortedDict
    1414
    15 try:
    16     sorted
    17 except NameError:
    18     from django.utils.itercompat import sorted  # For Python 2.3.
    19 
    20 
    2115class CyclicDependency(Exception):
    2216    """
    2317    An error when dealing with a collection of objects that have a cyclic
  • django/db/backends/sqlite3/base.py

     
    11"""
    22SQLite3 backend for django.
    33
    4 Python 2.3 and 2.4 require pysqlite2 (http://pysqlite.org/).
     4Python 2.4 requires pysqlite2 (http://pysqlite.org/).
    55
    66Python 2.5 and later can use a pysqlite2 module or the sqlite3 module in the
    77standard library.
     
    2929        module = 'either pysqlite2 or sqlite3 modules (tried in that order)'
    3030    raise ImproperlyConfigured, "Error loading %s: %s" % (module, exc)
    3131
    32 try:
    33     import decimal
    34 except ImportError:
    35     from django.utils import _decimal as decimal # for Python 2.3
    36 
    3732DatabaseError = Database.DatabaseError
    3833IntegrityError = Database.IntegrityError
    3934
  • django/db/backends/util.py

     
    33
    44from django.utils.hashcompat import md5_constructor
    55
    6 try:
    7     import decimal
    8 except ImportError:
    9     from django.utils import _decimal as decimal    # for Python 2.3
    10 
    116class CursorDebugWrapper(object):
    127    def __init__(self, cursor, db):
    138        self.cursor = cursor
  • django/db/backends/__init__.py

     
    44except ImportError:
    55    # Import copy of _thread_local.py from Python 2.4
    66    from django.utils._threading_local import local
    7 try:
    8     set
    9 except NameError:
    10     # Python 2.3 compat
    11     from sets import Set as set
    127
    13 try:
    14     import decimal
    15 except ImportError:
    16     # Python 2.3 fallback
    17     from django.utils import _decimal as decimal
    18 
    198from django.db.backends import util
    209from django.utils import datetime_safe
    2110
  • django/db/backends/creation.py

     
    11import sys
    22import time
    3 try:
    4     set
    5 except NameError:
    6     # Python 2.3 compat
    7     from sets import Set as set
    83
    94from django.conf import settings
    105from django.core.management import call_command
  • django/db/transaction.py

     
    1919try:
    2020    from functools import wraps
    2121except ImportError:
    22     from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
     22    from django.utils.functional import wraps  # Python 2.4 fallback.
    2323from django.db import connection
    2424from django.conf import settings
    2525
  • django/forms/models.py

     
    1515from widgets import media_property
    1616from formsets import BaseFormSet, formset_factory, DELETION_FIELD_NAME
    1717
    18 try:
    19     set
    20 except NameError:
    21     from sets import Set as set     # Python 2.3 fallback
    22 
    2318__all__ = (
    2419    'ModelForm', 'BaseModelForm', 'model_to_dict', 'fields_for_model',
    2520    'save_instance', 'form_for_fields', 'ModelChoiceField',
  • django/forms/fields.py

     
    1313except ImportError:
    1414    from StringIO import StringIO
    1515
    16 # Python 2.3 fallbacks
    17 try:
    18     from decimal import Decimal, DecimalException
    19 except ImportError:
    20     from django.utils._decimal import Decimal, DecimalException
    21 try:
    22     set
    23 except NameError:
    24     from sets import Set as set
    25 
    2616import django.core.exceptions
    2717from django.utils.translation import ugettext_lazy as _
    2818from django.utils.encoding import smart_unicode, smart_str
  • django/forms/widgets.py

     
    22HTML Widget classes
    33"""
    44
    5 try:
    6     set
    7 except NameError:
    8     from sets import Set as set   # Python 2.3 fallback
    9 
    105import copy
    116from itertools import chain
    127from django.conf import settings
  • django/core/serializers/json.py

     
    1010from django.utils import datetime_safe
    1111from django.utils import simplejson
    1212
    13 try:
    14     import decimal
    15 except ImportError:
    16     from django.utils import _decimal as decimal    # Python 2.3 fallback
    17 
    1813class Serializer(PythonSerializer):
    1914    """
    2015    Convert a queryset to JSON.
  • django/core/serializers/pyyaml.py

     
    77from StringIO import StringIO
    88import yaml
    99
    10 try:
    11     import decimal
    12 except ImportError:
    13     from django.utils import _decimal as decimal # Python 2.3 fallback
    14 
    1510from django.db import models
    1611from django.core.serializers.python import Serializer as PythonSerializer
    1712from django.core.serializers.python import Deserializer as PythonDeserializer
  • django/core/urlresolvers.py

     
    1818from django.utils.regex_helper import normalize
    1919from django.utils.thread_support import currentThread
    2020
    21 try:
    22     reversed
    23 except NameError:
    24     from django.utils.itercompat import reversed     # Python 2.3 fallback
    25     from sets import Set as set
    26 
    2721_resolver_cache = {} # Maps URLconf modules to RegexURLResolver instances.
    2822_callable_cache = {} # Maps view and url pattern names to their view functions.
    2923
  • django/core/cache/backends/locmem.py

     
    7777
    7878    def set(self, key, value, timeout=None):
    7979        self._lock.writer_enters()
    80         # Python 2.3 and 2.4 don't allow combined try-except-finally blocks.
     80        # Python 2.4 doesn't allow combined try-except-finally blocks.
    8181        try:
    8282            try:
    8383                self._set(key, pickle.dumps(value), timeout)
  • django/core/management/commands/makemessages.py

     
    88
    99from django.core.management.base import CommandError, BaseCommand
    1010
    11 try:
    12     set
    13 except NameError:
    14     from sets import Set as set     # For Python 2.3
    15 
    1611# Intentionally silence DeprecationWarnings about os.popen3 in Python 2.6. It's
    1712# still sensible for us to use it, since subprocess didn't exist in 2.3.
    1813warnings.filterwarnings('ignore', category=DeprecationWarning, message=r'os\.popen3')
  • django/core/management/commands/loaddata.py

     
    88from django.core.management.color import no_style
    99
    1010try:
    11     set
    12 except NameError:
    13     from sets import Set as set   # Python 2.3 fallback
    14 
    15 try:
    1611    import bz2
    1712    has_bz2 = True
    1813except ImportError:
  • django/core/management/commands/compilemessages.py

     
    33from optparse import make_option
    44from django.core.management.base import BaseCommand, CommandError
    55
    6 try:
    7     set
    8 except NameError:
    9     from sets import Set as set     # For Python 2.3
    10 
    116def compile_messages(locale=None):
    127    basedirs = [os.path.join('conf', 'locale'), 'locale']
    138    if os.environ.get('DJANGO_SETTINGS_MODULE'):
  • django/core/management/commands/syncdb.py

     
    44from optparse import make_option
    55import sys
    66
    7 try:
    8     set
    9 except NameError:
    10     from sets import Set as set   # Python 2.3 fallback
    11 
    127class Command(NoArgsCommand):
    138    option_list = NoArgsCommand.option_list + (
    149        make_option('--noinput', action='store_false', dest='interactive', default=True,
  • django/core/management/base.py

     
    1212from django.core.exceptions import ImproperlyConfigured
    1313from django.core.management.color import color_style
    1414
    15 try:
    16     set
    17 except NameError:
    18     from sets import Set as set     # For Python 2.3
    19 
    2015class CommandError(Exception):
    2116    """
    2217    Exception class indicating a problem while executing a management
  • django/core/management/sql.py

     
    22import os
    33import re
    44
    5 try:
    6     set
    7 except NameError:
    8     from sets import Set as set   # Python 2.3 fallback
    9 
    105def sql_create(app, style):
    116    "Returns a list of the CREATE TABLE SQL statements for the given app."
    127    from django.db import connection, models
  • django/views/decorators/csrf.py

     
    33try:
    44    from functools import wraps
    55except ImportError:
    6     from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
     6    from django.utils.functional import wraps  # Python 2.4 fallback.
    77
    88csrf_protect = decorator_from_middleware(CsrfViewMiddleware)
    99csrf_protect.__name__ = "csrf_protect"
  • django/views/decorators/http.py

     
    55try:
    66    from functools import wraps
    77except ImportError:
    8     from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
     8    from django.utils.functional import wraps  # Python 2.4 fallback.
    99
    1010from calendar import timegm
    1111from datetime import timedelta
  • django/views/decorators/vary.py

     
    11try:
    22    from functools import wraps
    33except ImportError:
    4     from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
     4    from django.utils.functional import wraps  # Python 2.4 fallback.
    55
    66from django.utils.cache import patch_vary_headers
    77
  • django/views/decorators/cache.py

     
    1414try:
    1515    from functools import wraps
    1616except ImportError:
    17     from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
     17    from django.utils.functional import wraps  # Python 2.4 fallback.
    1818
    1919from django.utils.decorators import decorator_from_middleware_with_args, auto_adapt_to_methods
    2020from django.utils.cache import patch_cache_control, add_never_cache_headers
  • django/dispatch/dispatcher.py

     
    11import weakref
    2 try:
    3     set
    4 except NameError:
    5     from sets import Set as set # Python 2.3 fallback
    62
    73from django.dispatch import saferef
    84
  • django/utils/translation/trans_real.py

     
    5656    """
    5757    This class sets up the GNUTranslations context with regard to output
    5858    charset. Django uses a defined DEFAULT_CHARSET as the output charset on
    59     Python 2.4. With Python 2.3, use DjangoTranslation23.
     59    Python 2.4.
    6060    """
    6161    def __init__(self, *args, **kw):
    6262        from django.conf import settings
     
    8383    def __repr__(self):
    8484        return "<DjangoTranslation lang:%s>" % self.__language
    8585
    86 class DjangoTranslation23(DjangoTranslation):
    87     """
    88     Compatibility class that is only used with Python 2.3.
    89     Python 2.3 doesn't support set_output_charset on translation objects and
    90     needs this wrapper class to make sure input charsets from translation files
    91     are correctly translated to output charsets.
    92 
    93     With a full switch to Python 2.4, this can be removed from the source.
    94     """
    95     def gettext(self, msgid):
    96         res = self.ugettext(msgid)
    97         return res.encode(self.django_output_charset)
    98 
    99     def ngettext(self, msgid1, msgid2, n):
    100         res = self.ungettext(msgid1, msgid2, n)
    101         return res.encode(self.django_output_charset)
    102 
    10386def translation(language):
    10487    """
    10588    Returns a translation object.
     
    119102
    120103    # set up the right translation class
    121104    klass = DjangoTranslation
    122     if sys.version_info < (2, 4):
    123         klass = DjangoTranslation23
    124105
    125106    globalpath = os.path.join(os.path.dirname(sys.modules[settings.__module__].__file__), 'locale')
    126107
  • django/utils/functional.py

     
    6060# Summary of changes made to the Python 2.5 code below:
    6161#   * swapped ``partial`` for ``curry`` to maintain backwards-compatibility
    6262#     in Django.
    63 #   * Wrapped the ``setattr`` call in ``update_wrapper`` with a try-except
    64 #     block to make it compatible with Python 2.3, which doesn't allow
    65 #     assigning to ``__name__``.
    6663
    6764# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Python Software Foundation.
    6865# All Rights Reserved.
     
    9087       function (defaults to functools.WRAPPER_UPDATES)
    9188    """
    9289    for attr in assigned:
    93         try:
    94             setattr(wrapper, attr, getattr(wrapped, attr))
    95         except TypeError: # Python 2.3 doesn't allow assigning to __name__.
    96             pass
     90        setattr(wrapper, attr, getattr(wrapped, attr))
    9791    for attr in updated:
    9892        getattr(wrapper, attr).update(getattr(wrapped, attr))
    9993    # Return the wrapper so this can be used as a decorator via curry()
  • django/utils/cache.py

     
    1919
    2020import re
    2121import time
    22 try:
    23     set
    24 except NameError:
    25     from sets import Set as set   # Python 2.3 fallback
    2622
    2723from django.conf import settings
    2824from django.core.cache import cache
  • django/utils/decorators.py

     
    44try:
    55    from functools import wraps, update_wrapper
    66except ImportError:
    7     from django.utils.functional import wraps, update_wrapper  # Python 2.3, 2.4 fallback.
     7    from django.utils.functional import wraps, update_wrapper  # Python 2.4 fallback.
    88
    99
    1010# Licence for MethodDecoratorAdaptor and auto_adapt_to_methods
  • django/utils/encoding.py

     
    66
    77from django.utils.functional import Promise
    88
    9 try:
    10     from decimal import Decimal
    11 except ImportError:
    12     from django.utils._decimal import Decimal # Python 2.3 fallback
    13 
    14 
    159class DjangoUnicodeDecodeError(UnicodeDecodeError):
    1610    def __init__(self, obj, *args):
    1711        self.obj = obj
  • django/contrib/formtools/utils.py

     
    3232    data.append(settings.SECRET_KEY)
    3333
    3434    # Use HIGHEST_PROTOCOL because it's the most efficient. It requires
    35     # Python 2.3, but Django requires 2.3 anyway, so that's OK.
     35    # Python 2.3, but Django requires 2.4 anyway, so that's OK.
    3636    pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
    3737
    3838    return md5_constructor(pickled).hexdigest()
  • django/contrib/admin/validation.py

     
    1 try:
    2     set
    3 except NameError:
    4     from sets import Set as set   # Python 2.3 fallback
    5 
    61from django.core.exceptions import ImproperlyConfigured
    72from django.db import models
    83from django.forms.models import BaseModelForm, BaseModelFormSet, fields_for_model, _get_foreign_key
  • django/contrib/admin/options.py

     
    2121from django.utils.translation import ugettext as _
    2222from django.utils.translation import ungettext, ugettext_lazy
    2323from django.utils.encoding import force_unicode
    24 try:
    25     set
    26 except NameError:
    27     from sets import Set as set     # Python 2.3 fallback
    2824
    2925HORIZONTAL, VERTICAL = 1, 2
    3026# returns the <ul> class for a given radio_admin field
  • django/contrib/admin/actions.py

     
    1212from django.utils.safestring import mark_safe
    1313from django.utils.text import capfirst
    1414from django.utils.translation import ugettext_lazy, ugettext as _
    15 try:
    16     set
    17 except NameError:
    18     from sets import Set as set     # Python 2.3 fallback
    1915
    2016def delete_selected(modeladmin, request, queryset):
    2117    """
  • django/contrib/admin/views/main.py

     
    99from django.utils.http import urlencode
    1010import operator
    1111
    12 try:
    13     set
    14 except NameError:
    15     from sets import Set as set   # Python 2.3 fallback
    16 
    1712# The system will display a "Show all" link on the change list only if the
    1813# total result count is less than or equal to this setting.
    1914MAX_SHOW_ALL_ALLOWED = 200
  • django/contrib/admin/views/decorators.py

     
    22try:
    33    from functools import wraps
    44except ImportError:
    5     from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
     5    from django.utils.functional import wraps  # Python 2.4 fallback.
    66
    77from django import http, template
    88from django.conf import settings
  • django/contrib/admin/sites.py

     
    1414from django.utils.translation import ugettext_lazy, ugettext as _
    1515from django.views.decorators.cache import never_cache
    1616from django.conf import settings
    17 try:
    18     set
    19 except NameError:
    20     from sets import Set as set     # Python 2.3 fallback
    2117
    2218ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
    2319LOGIN_FORM_KEY = 'this_is_the_login_form'
  • django/contrib/auth/decorators.py

     
    11try:
    22    from functools import update_wrapper, wraps
    33except ImportError:
    4     from django.utils.functional import update_wrapper, wraps  # Python 2.3, 2.4 fallback.
     4    from django.utils.functional import update_wrapper, wraps  # Python 2.4 fallback.
    55
    66from django.contrib.auth import REDIRECT_FIELD_NAME
    77from django.http import HttpResponseRedirect
  • django/contrib/auth/backends.py

     
    1 try:
    2     set
    3 except NameError:
    4     from sets import Set as set # Python 2.3 fallback
    5 
    61from django.db import connection
    72from django.contrib.auth.models import User
    83
    9 
    104class ModelBackend(object):
    115    """
    126    Authenticates against django.contrib.auth.models.User.
  • django/contrib/auth/models.py

     
    1212
    1313UNUSABLE_PASSWORD = '!' # This will never be a valid hash
    1414
    15 try:
    16     set
    17 except NameError:
    18     from sets import Set as set   # Python 2.3 fallback
    19 
    2015def get_hexdigest(algorithm, salt, raw_password):
    2116    """
    2217    Returns a string of the hexdigest of the given plaintext password and salt
  • django/contrib/localflavor/br/forms.py

     
    99from django.utils.translation import ugettext_lazy as _
    1010import re
    1111
    12 try:
    13     set
    14 except NameError:
    15     from sets import Set as set     # For Python 2.3
    16 
    1712phone_digits_re = re.compile(r'^(\d{2})[-\.]?(\d{4})[-\.]?(\d{4})$')
    1813
    1914class BRZipCodeField(RegexField):
  • django/template/defaultfilters.py

     
    1111try:
    1212    from functools import wraps
    1313except ImportError:
    14     from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
     14    from django.utils.functional import wraps  # Python 2.4 fallback.
    1515
    1616from django.template import Variable, Library
    1717from django.conf import settings
  • django/template/defaulttags.py

     
    33import sys
    44import re
    55from itertools import cycle as itertools_cycle
    6 try:
    7     reversed
    8 except NameError:
    9     from django.utils.itercompat import reversed     # Python 2.3 fallback
    106
    117from django.template import Node, NodeList, Template, Context, Variable
    128from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END
  • tests/modeltests/basic/models.py

     
    44
    55This is a basic model with only two non-primary-key fields.
    66"""
    7 # Python 2.3 doesn't have set as a builtin
    8 try:
    9     set
    10 except NameError:
    11     from sets import Set as set
    127
    13 # Python 2.3 doesn't have sorted()
    14 try:
    15     sorted
    16 except NameError:
    17     from django.utils.itercompat import sorted
    18 
    198from django.db import models
    209
    2110class Article(models.Model):
  • tests/modeltests/or_lookups/models.py

     
    88clauses using the variable ``django.db.models.Q`` (or any object with an
    99``add_to_query`` method).
    1010"""
    11 # Python 2.3 doesn't have sorted()
    12 try:
    13     sorted
    14 except NameError:
    15     from django.utils.itercompat import sorted
    1611
    1712from django.db import models
    1813
  • tests/modeltests/aggregation/models.py

     
    11# coding: utf-8
    22from django.db import models
    33
    4 try:
    5     sorted
    6 except NameError:
    7     from django.utils.itercompat import sorted      # For Python 2.3
    8 
    94class Author(models.Model):
    105    name = models.CharField(max_length=100)
    116    age = models.IntegerField()
  • tests/modeltests/serializers/models.py

     
    66``QuerySet`` objects to and from "flat" data (i.e. strings).
    77"""
    88
    9 try:
    10     from decimal import Decimal
    11 except ImportError:
    12     from django.utils._decimal import Decimal # Python 2.3 fallback
    13 
    149from django.db import models
    1510
    1611class Category(models.Model):
  • tests/modeltests/model_forms/models.py

     
    1313from django.db import models
    1414from django.core.files.storage import FileSystemStorage
    1515
    16 # Python 2.3 doesn't have sorted()
    17 try:
    18     sorted
    19 except NameError:
    20     from django.utils.itercompat import sorted
    21 
    2216temp_storage_dir = tempfile.mkdtemp()
    2317temp_storage = FileSystemStorage(temp_storage_dir)
    2418
  • tests/regressiontests/model_inheritance_regress/models.py

     
    66
    77from django.db import models
    88
    9 # Python 2.3 doesn't have sorted()
    10 try:
    11     sorted
    12 except NameError:
    13     from django.utils.itercompat import sorted
    14 
    159class Place(models.Model):
    1610    name = models.CharField(max_length=50)
    1711    address = models.CharField(max_length=80)
  • tests/regressiontests/defaultfilters/tests.py

     
    571571from django.template.defaultfilters import *
    572572import datetime
    573573
    574 # Python 2.3 doesn't have sorted()
    575 try:
    576     sorted
    577 except NameError:
    578     from django.utils.itercompat import sorted
    579 
    580574if __name__ == '__main__':
    581575    import doctest
    582576    doctest.testmod()
  • tests/regressiontests/aggregation_regress/models.py

     
    44from django.db import connection, models
    55from django.conf import settings
    66
    7 try:
    8     sorted
    9 except NameError:
    10     from django.utils.itercompat import sorted      # For Python 2.3
    11 
    127class Author(models.Model):
    138    name = models.CharField(max_length=100)
    149    age = models.IntegerField()
  • tests/regressiontests/decorators/tests.py

     
    33try:
    44    from functools import wraps
    55except ImportError:
    6     from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
     6    from django.utils.functional import wraps  # Python 2.4 fallback.
    77
    88from django.http import HttpResponse, HttpRequest
    99from django.utils.functional import allow_lazy, lazy, memoize
  • tests/regressiontests/i18n/misc.py

     
    8787'es-ar'
    8888"""
    8989
    90 # Python 2.3 and 2.4 return slightly different results for completely bogus
     90# Python 2.4 returns slightly different results for completely bogus
    9191# locales, so we omit this test for that anything below 2.4. It's relatively
    9292# harmless in any cases (GIGO). This also means this won't be executed on
    9393# Jython currently, but life's like that sometimes. (On those platforms,
  • tests/regressiontests/model_fields/models.py

     
    22import tempfile
    33
    44try:
    5     import decimal
    6 except ImportError:
    7     from django.utils import _decimal as decimal    # Python 2.3 fallback
    8 
    9 try:
    105    # Checking for the existence of Image is enough for CPython, but for PyPy,
    116    # you need to check for the underlying modules.
    127    from PIL import Image, _imaging
  • tests/regressiontests/auth_backends/tests.py

     
    1 try:
    2     set
    3 except NameError:
    4     from sets import Set as set     # Python 2.3 fallback
    5 
    61__test__ = {'API_TESTS': """
    72>>> from django.contrib.auth.models import User, Group, Permission, AnonymousUser
    83>>> from django.contrib.contenttypes.models import ContentType
  • tests/regressiontests/admin_scripts/management/commands/base_command.py

     
    11from django.core.management.base import BaseCommand
    22from optparse import make_option
    3 # Python 2.3 doesn't have sorted()
    4 try:
    5     sorted
    6 except NameError:
    7     from django.utils.itercompat import sorted
    83
    94class Command(BaseCommand):
    105    option_list = BaseCommand.option_list + (
  • tests/regressiontests/admin_scripts/management/commands/label_command.py

     
    11from django.core.management.base import LabelCommand
    2 # Python 2.3 doesn't have sorted()
    3 try:
    4     sorted
    5 except NameError:
    6     from django.utils.itercompat import sorted
    72
    83class Command(LabelCommand):
    94    help = "Test Label-based commands"
  • tests/regressiontests/admin_scripts/management/commands/app_command.py

     
    11from django.core.management.base import AppCommand
    2 # Python 2.3 doesn't have sorted()
    3 try:
    4     sorted
    5 except NameError:
    6     from django.utils.itercompat import sorted
    72
    83class Command(AppCommand):
    94    help = 'Test Application-based commands'
  • tests/regressiontests/admin_scripts/management/commands/noargs_command.py

     
    11from django.core.management.base import NoArgsCommand
    2 # Python 2.3 doesn't have sorted()
    3 try:
    4     sorted
    5 except NameError:
    6     from django.utils.itercompat import sorted
    72
    83class Command(NoArgsCommand):
    94    help = "Test No-args commands"
  • tests/regressiontests/utils/tests.py

     
    1313import itercompat
    1414from decorators import DecoratorFromMiddlewareTests
    1515
    16 # We need this because "datastructures" uses sorted() and the tests are run in
    17 # the scope of this module.
    18 try:
    19     sorted
    20 except NameError:
    21     from django.utils.itercompat import sorted  # For Python 2.3
    22 
    2316# Extra tests
    2417__test__ = {
    2518    'timesince': timesince,
  • tests/regressiontests/introspection/tests.py

     
    55
    66from models import Reporter, Article
    77
    8 try:
    9     set
    10 except NameError:
    11     from sets import Set as set     # Python 2.3 fallback
    12 
    138#
    149# The introspection module is optional, so methods tested here might raise
    1510# NotImplementedError. This is perfectly acceptable behavior for the backend
  • tests/regressiontests/queries/models.py

     
    1010from django.db import models
    1111from django.db.models.query import Q, ITER_CHUNK_SIZE
    1212
    13 # Python 2.3 doesn't have sorted()
    14 try:
    15     sorted
    16 except NameError:
    17     from django.utils.itercompat import sorted
    18 
    1913class DumbCategory(models.Model):
    2014    pass
    2115
     
    11781172
    11791173"""}
    11801174
    1181 # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__
     1175# In Python 2.6 beta releases, exceptions raised in __len__
    11821176# are swallowed (Python issue 1242657), so these cases return an empty list,
    11831177# rather than raising an exception. Not a lot we can do about that,
    11841178# unfortunately, due to the way Python handles list() calls internally. Thus,
    1185 # we skip the tests for Python 2.3 and 2.6.
    1186 if (2, 4) <= sys.version_info < (2, 6):
     1179# we skip the tests for Python 2.6.
     1180if sys.version_info < (2, 6):
    11871181    __test__["API_TESTS"] += """
    11881182# If you're not careful, it's possible to introduce infinite loops via default
    11891183# ordering on foreign keys in a cycle. We detect that.
  • tests/runtests.py

     
    55
    66import django.contrib as contrib
    77
    8 try:
    9     set
    10 except NameError:
    11     from sets import Set as set     # For Python 2.3
    12 
    13 
    148CONTRIB_DIR_NAME = 'django.contrib'
    159MODEL_TESTS_DIR_NAME = 'modeltests'
    1610REGRESSION_TESTS_DIR_NAME = 'regressiontests'
Back to Top