Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #12164 -- Removed the Python 2.3 compatibility imports and work…

…arounds. Thanks to timo and claudep for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5211f48ae3cc0d87a260dbf5c3ab8bdae664c4b6 1 parent 7202eb8
@freakboy3742 freakboy3742 authored
Showing with 32 additions and 3,399 deletions.
  1. +0 −4 django/contrib/admin/actions.py
  2. +0 −4 django/contrib/admin/options.py
  3. +0 −4 django/contrib/admin/sites.py
  4. +1 −1  django/contrib/admin/views/decorators.py
  5. +0 −5 django/contrib/admin/views/main.py
  6. +0 −5 django/contrib/auth/backends.py
  7. +1 −1  django/contrib/auth/decorators.py
  8. +1 −1  django/contrib/formtools/utils.py
  9. +0 −5 django/contrib/localflavor/br/forms.py
  10. +0 −5 django/contrib/messages/storage/fallback.py
  11. +1 −1  django/core/cache/backends/locmem.py
  12. +0 −5 django/core/management/base.py
  13. +0 −5 django/core/management/sql.py
  14. +1 −5 django/core/serializers/json.py
  15. +0 −6 django/core/urlresolvers.py
  16. +0 −5 django/db/backends/creation.py
  17. +1 −4 django/db/backends/oracle/base.py
  18. +1 −1  django/db/backends/sqlite3/base.py
  19. +1 −5 django/db/backends/util.py
  20. +1 −1  django/db/models/fields/__init__.py
  21. +0 −4 django/db/models/options.py
  22. +1 −1  django/db/transaction.py
  23. +0 −4 django/dispatch/dispatcher.py
  24. +0 −5 django/forms/models.py
  25. +2 −7 django/template/defaultfilters.py
  26. +1 −2  django/template/defaulttags.py
  27. +0 −8 django/test/simple.py
  28. +0 −3,079 django/utils/_decimal.py
  29. +1 −1  django/utils/decorators.py
  30. +1 −6 django/utils/encoding.py
  31. +1 −7 django/utils/functional.py
  32. +1 −57 django/utils/itercompat.py
  33. +1 −1  django/views/decorators/cache.py
  34. +1 −1  django/views/decorators/csrf.py
  35. +1 −1  django/views/decorators/http.py
  36. +1 −1  django/views/decorators/vary.py
  37. +1 −9 tests/modeltests/aggregation/models.py
  38. +0 −12 tests/modeltests/basic/models.py
  39. +0 −5 tests/modeltests/model_formsets/models.py
  40. +0 −5 tests/modeltests/or_lookups/models.py
  41. +1 −5 tests/modeltests/serializers/models.py
  42. +0 −5 tests/regressiontests/admin_scripts/management/commands/app_command.py
  43. +0 −5 tests/regressiontests/admin_scripts/management/commands/base_command.py
  44. +0 −5 tests/regressiontests/admin_scripts/management/commands/label_command.py
  45. +0 −5 tests/regressiontests/admin_scripts/management/commands/noargs_command.py
  46. +0 −5 tests/regressiontests/aggregation_regress/models.py
  47. +1 −1  tests/regressiontests/decorators/tests.py
  48. +0 −6 tests/regressiontests/defaultfilters/tests.py
  49. +1 −4 tests/regressiontests/forms/extra.py
  50. +1 −5 tests/regressiontests/forms/fields.py
  51. +1 −4 tests/regressiontests/forms/forms.py
  52. +1 −4 tests/regressiontests/forms/widgets.py
  53. +0 −5 tests/regressiontests/model_fields/models.py
  54. +1 −6 tests/regressiontests/model_fields/tests.py
  55. +0 −6 tests/regressiontests/model_inheritance_regress/models.py
  56. +3 −9 tests/regressiontests/queries/models.py
  57. +0 −15 tests/regressiontests/utils/itercompat.py
  58. +0 −9 tests/regressiontests/utils/tests.py
  59. +0 −6 tests/runtests.py
View
4 django/contrib/admin/actions.py
@@ -12,10 +12,6 @@
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy, ugettext as _
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
def delete_selected(modeladmin, request, queryset):
"""
View
4 django/contrib/admin/options.py
@@ -23,10 +23,6 @@
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext, ugettext_lazy
from django.utils.encoding import force_unicode
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
HORIZONTAL, VERTICAL = 1, 2
# returns the <ul> class for a given radio_admin field
View
4 django/contrib/admin/sites.py
@@ -14,10 +14,6 @@
from django.utils.translation import ugettext_lazy, ugettext as _
from django.views.decorators.cache import never_cache
from django.conf import settings
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
LOGIN_FORM_KEY = 'this_is_the_login_form'
View
2  django/contrib/admin/views/decorators.py
@@ -2,7 +2,7 @@
try:
from functools import wraps
except ImportError:
- from django.utils.functional import wraps # Python 2.3, 2.4 fallback.
+ from django.utils.functional import wraps # Python 2.4 fallback.
from django import http, template
from django.conf import settings
View
5 django/contrib/admin/views/main.py
@@ -9,11 +9,6 @@
from django.utils.http import urlencode
import operator
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
-
# The system will display a "Show all" link on the change list only if the
# total result count is less than or equal to this setting.
MAX_SHOW_ALL_ALLOWED = 200
View
5 django/contrib/auth/backends.py
@@ -1,8 +1,3 @@
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
-
from django.db import connection
from django.contrib.auth.models import User, Permission
View
2  django/contrib/auth/decorators.py
@@ -1,7 +1,7 @@
try:
from functools import update_wrapper, wraps
except ImportError:
- from django.utils.functional import update_wrapper, wraps # Python 2.3, 2.4 fallback.
+ from django.utils.functional import update_wrapper, wraps # Python 2.4 fallback.
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.http import HttpResponseRedirect
View
2  django/contrib/formtools/utils.py
@@ -32,7 +32,7 @@ def security_hash(request, form, *args):
data.append(settings.SECRET_KEY)
# Use HIGHEST_PROTOCOL because it's the most efficient. It requires
- # Python 2.3, but Django requires 2.3 anyway, so that's OK.
+ # Python 2.3, but Django requires 2.4 anyway, so that's OK.
pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
return md5_constructor(pickled).hexdigest()
View
5 django/contrib/localflavor/br/forms.py
@@ -10,11 +10,6 @@
from django.utils.translation import ugettext_lazy as _
import re
-try:
- set
-except NameError:
- from sets import Set as set # For Python 2.3
-
phone_digits_re = re.compile(r'^(\d{2})[-\.]?(\d{4})[-\.]?(\d{4})$')
class BRZipCodeField(RegexField):
View
5 django/contrib/messages/storage/fallback.py
@@ -1,11 +1,6 @@
from django.contrib.messages.storage.base import BaseStorage
from django.contrib.messages.storage.cookie import CookieStorage
from django.contrib.messages.storage.session import SessionStorage
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3
-
class FallbackStorage(BaseStorage):
"""
View
2  django/core/cache/backends/locmem.py
@@ -77,7 +77,7 @@ def _set(self, key, value, timeout=None):
def set(self, key, value, timeout=None):
self._lock.writer_enters()
- # Python 2.3 and 2.4 don't allow combined try-except-finally blocks.
+ # Python 2.4 doesn't allow combined try-except-finally blocks.
try:
try:
self._set(key, pickle.dumps(value), timeout)
View
5 django/core/management/base.py
@@ -13,11 +13,6 @@
from django.core.management.color import color_style
from django.utils.encoding import smart_str
-try:
- set
-except NameError:
- from sets import Set as set # For Python 2.3
-
class CommandError(Exception):
"""
Exception class indicating a problem while executing a management
View
5 django/core/management/sql.py
@@ -9,11 +9,6 @@
from django.db.models import get_models
from django.db.backends.util import truncate_name
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
-
def sql_create(app, style, connection):
"Returns a list of the CREATE TABLE SQL statements for the given app."
View
6 django/core/serializers/json.py
@@ -3,6 +3,7 @@
"""
import datetime
+import decimal
from StringIO import StringIO
from django.core.serializers.python import Serializer as PythonSerializer
@@ -10,11 +11,6 @@
from django.utils import datetime_safe
from django.utils import simplejson
-try:
- import decimal
-except ImportError:
- from django.utils import _decimal as decimal # Python 2.3 fallback
-
class Serializer(PythonSerializer):
"""
Convert a queryset to JSON.
View
6 django/core/urlresolvers.py
@@ -19,12 +19,6 @@
from django.utils.regex_helper import normalize
from django.utils.thread_support import currentThread
-try:
- reversed
-except NameError:
- from django.utils.itercompat import reversed # Python 2.3 fallback
- from sets import Set as set
-
_resolver_cache = {} # Maps URLconf modules to RegexURLResolver instances.
_callable_cache = {} # Maps view and url pattern names to their view functions.
View
5 django/db/backends/creation.py
@@ -1,10 +1,5 @@
import sys
import time
-try:
- set
-except NameError:
- # Python 2.3 compat
- from sets import Set as set
from django.conf import settings
from django.core.management import call_command
View
5 django/db/backends/oracle/base.py
@@ -9,10 +9,7 @@
import os
import sys
import time
-try:
- from decimal import Decimal
-except ImportError:
- from django.utils._decimal import Decimal
+from decimal import Decimal
# Oracle takes client-side character set encoding from the environment.
os.environ['NLS_LANG'] = '.UTF8'
View
2  django/db/backends/sqlite3/base.py
@@ -1,7 +1,7 @@
"""
SQLite3 backend for django.
-Python 2.3 and 2.4 require pysqlite2 (http://pysqlite.org/).
+Python 2.4 requires pysqlite2 (http://pysqlite.org/).
Python 2.5 and later can use a pysqlite2 module or the sqlite3 module in the
standard library.
View
6 django/db/backends/util.py
@@ -1,13 +1,9 @@
import datetime
+import decimal
from time import time
from django.utils.hashcompat import md5_constructor
-try:
- import decimal
-except ImportError:
- from django.utils import _decimal as decimal # for Python 2.3
-
class CursorDebugWrapper(object):
def __init__(self, cursor, db):
self.cursor = cursor
View
2  django/db/models/fields/__init__.py
@@ -3,6 +3,7 @@
import re
import time
import math
+from itertools import tee
import django.utils.copycompat as copy
@@ -14,7 +15,6 @@
from django.core import exceptions, validators
from django.utils.datastructures import DictWrapper
from django.utils.functional import curry
-from django.utils.itercompat import tee
from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode, force_unicode, smart_str
View
4 django/db/models/options.py
@@ -1,9 +1,5 @@
import re
from bisect import bisect
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
from django.conf import settings
from django.db.models.related import RelatedObject
View
2  django/db/transaction.py
@@ -19,7 +19,7 @@
try:
from functools import wraps
except ImportError:
- from django.utils.functional import wraps # Python 2.3, 2.4 fallback.
+ from django.utils.functional import wraps # Python 2.4 fallback.
from django.db import connections, DEFAULT_DB_ALIAS
from django.conf import settings
View
4 django/dispatch/dispatcher.py
@@ -1,8 +1,4 @@
import weakref
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
from django.dispatch import saferef
View
5 django/forms/models.py
@@ -18,11 +18,6 @@
from widgets import media_property
from formsets import BaseFormSet, formset_factory, DELETION_FIELD_NAME
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
-
__all__ = (
'ModelForm', 'BaseModelForm', 'model_to_dict', 'fields_for_model',
'save_instance', 'form_for_fields', 'ModelChoiceField',
View
9 django/template/defaultfilters.py
@@ -1,17 +1,12 @@
"""Default variable filters."""
import re
-
-try:
- from decimal import Decimal, InvalidOperation, ROUND_HALF_UP
-except ImportError:
- from django.utils._decimal import Decimal, InvalidOperation, ROUND_HALF_UP
-
+from decimal import Decimal, InvalidOperation, ROUND_HALF_UP
import random as random_module
try:
from functools import wraps
except ImportError:
- from django.utils.functional import wraps # Python 2.3, 2.4 fallback.
+ from django.utils.functional import wraps # Python 2.4 fallback.
from django.template import Variable, Library
from django.conf import settings
View
3  django/template/defaulttags.py
@@ -2,7 +2,7 @@
import sys
import re
-from itertools import cycle as itertools_cycle
+from itertools import groupby, cycle as itertools_cycle
from django.template import Node, NodeList, Template, Context, Variable
from 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
@@ -10,7 +10,6 @@
from django.template.smartif import IfParser, Literal
from django.conf import settings
from django.utils.encoding import smart_str, smart_unicode
-from django.utils.itercompat import groupby
from django.utils.safestring import mark_safe
register = Library()
View
8 django/test/simple.py
@@ -185,14 +185,6 @@ def build_test(label):
# Construct a suite out of the tests that matched.
return unittest.TestSuite(tests)
-# Python 2.3 compatibility: TestSuites were made iterable in 2.4.
-# We need to iterate over them, so we add the missing method when
-# necessary.
-try:
- getattr(unittest.TestSuite, '__iter__')
-except AttributeError:
- setattr(unittest.TestSuite, '__iter__', lambda s: iter(s._tests))
-
def partition_suite(suite, classes, bins):
"""
Partitions a test suite by test type.
View
3,079 django/utils/_decimal.py
0 additions, 3,079 deletions not shown
View
2  django/utils/decorators.py
@@ -4,7 +4,7 @@
try:
from functools import wraps, update_wrapper, WRAPPER_ASSIGNMENTS
except ImportError:
- from django.utils.functional import wraps, update_wrapper, WRAPPER_ASSIGNMENTS # Python 2.3, 2.4 fallback.
+ from django.utils.functional import wraps, update_wrapper, WRAPPER_ASSIGNMENTS # Python 2.4 fallback.
def method_decorator(decorator):
View
7 django/utils/encoding.py
@@ -3,15 +3,10 @@
import locale
import datetime
import codecs
+from decimal import Decimal
from django.utils.functional import Promise
-try:
- from decimal import Decimal
-except ImportError:
- from django.utils._decimal import Decimal # Python 2.3 fallback
-
-
class DjangoUnicodeDecodeError(UnicodeDecodeError):
def __init__(self, obj, *args):
self.obj = obj
View
8 django/utils/functional.py
@@ -60,9 +60,6 @@ def _curried(*moreargs, **morekwargs):
# Summary of changes made to the Python 2.5 code below:
# * swapped ``partial`` for ``curry`` to maintain backwards-compatibility
# in Django.
-# * Wrapped the ``setattr`` call in ``update_wrapper`` with a try-except
-# block to make it compatible with Python 2.3, which doesn't allow
-# assigning to ``__name__``.
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Python Software Foundation.
# All Rights Reserved.
@@ -90,10 +87,7 @@ def update_wrapper(wrapper,
function (defaults to functools.WRAPPER_UPDATES)
"""
for attr in assigned:
- try:
- setattr(wrapper, attr, getattr(wrapped, attr))
- except TypeError: # Python 2.3 doesn't allow assigning to __name__.
- pass
+ setattr(wrapper, attr, getattr(wrapped, attr))
for attr in updated:
getattr(wrapper, attr).update(getattr(wrapped, attr))
# Return the wrapper so this can be used as a decorator via curry()
View
58 django/utils/itercompat.py
@@ -6,45 +6,7 @@
import itertools
-def compat_tee(iterable):
- """
- Return two independent iterators from a single iterable.
-
- Based on http://www.python.org/doc/2.3.5/lib/itertools-example.html
- """
- # Note: Using a dictionary and a list as the default arguments here is
- # deliberate and safe in this instance.
- def gen(next, data={}, cnt=[0]):
- dpop = data.pop
- for i in itertools.count():
- if i == cnt[0]:
- item = data[i] = next()
- cnt[0] += 1
- else:
- item = dpop(i)
- yield item
- next = iter(iterable).next
- return gen(next), gen(next)
-
-def groupby(iterable, keyfunc=None):
- """
- Taken from http://docs.python.org/lib/itertools-functions.html
- """
- if keyfunc is None:
- keyfunc = lambda x:x
- iterable = iter(iterable)
- l = [iterable.next()]
- lastkey = keyfunc(l[0])
- for item in iterable:
- key = keyfunc(item)
- if key != lastkey:
- yield lastkey, l
- lastkey = key
- l = [item]
- else:
- l.append(item)
- yield lastkey, l
-
+# Fallback for Python 2.4, Python 2.5
def product(*args, **kwds):
"""
Taken from http://docs.python.org/library/itertools.html#itertools.product
@@ -58,18 +20,6 @@ def product(*args, **kwds):
for prod in result:
yield tuple(prod)
-# Not really in itertools, since it's a builtin in Python 2.4 and later, but it
-# does operate as an iterator.
-def reversed(data):
- for index in xrange(len(data)-1, -1, -1):
- yield data[index]
-
-if hasattr(itertools, 'tee'):
- tee = itertools.tee
-else:
- tee = compat_tee
-if hasattr(itertools, 'groupby'):
- groupby = itertools.groupby
if hasattr(itertools, 'product'):
product = itertools.product
@@ -82,12 +32,6 @@ def is_iterable(x):
else:
return True
-def sorted(in_value):
- "A naive implementation of sorted"
- out_value = in_value[:]
- out_value.sort()
- return out_value
-
def all(iterable):
for item in iterable:
if not item:
View
2  django/views/decorators/cache.py
@@ -14,7 +14,7 @@
try:
from functools import wraps
except ImportError:
- from django.utils.functional import wraps # Python 2.3, 2.4 fallback.
+ from django.utils.functional import wraps # Python 2.4 fallback.
from django.utils.decorators import decorator_from_middleware_with_args, available_attrs
from django.utils.cache import patch_cache_control, add_never_cache_headers
View
2  django/views/decorators/csrf.py
@@ -4,7 +4,7 @@
try:
from functools import wraps
except ImportError:
- from django.utils.functional import wraps # Python 2.3, 2.4 fallback.
+ from django.utils.functional import wraps # Python 2.4 fallback.
csrf_protect = decorator_from_middleware(CsrfViewMiddleware)
csrf_protect.__name__ = "csrf_protect"
View
2  django/views/decorators/http.py
@@ -5,7 +5,7 @@
try:
from functools import wraps
except ImportError:
- from django.utils.functional import wraps # Python 2.3, 2.4 fallback.
+ from django.utils.functional import wraps # Python 2.4 fallback.
from calendar import timegm
from datetime import timedelta
View
2  django/views/decorators/vary.py
@@ -1,7 +1,7 @@
try:
from functools import wraps
except ImportError:
- from django.utils.functional import wraps # Python 2.3, 2.4 fallback.
+ from django.utils.functional import wraps # Python 2.4 fallback.
from django.utils.cache import patch_vary_headers
from django.utils.decorators import available_attrs
View
10 tests/modeltests/aggregation/models.py
@@ -1,11 +1,6 @@
# coding: utf-8
from django.db import models
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted # For Python 2.3
-
class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
@@ -48,10 +43,7 @@ def __unicode__(self):
# Different backends and numbers.
__test__ = {'API_TESTS': """
>>> from django.core import management
->>> try:
-... from decimal import Decimal
-... except:
-... from django.utils._decimal import Decimal
+>>> from decimal import Decimal
>>> from datetime import date
# Reset the database representation of this app.
View
12 tests/modeltests/basic/models.py
@@ -4,18 +4,6 @@
This is a basic model with only two non-primary-key fields.
"""
-# Python 2.3 doesn't have set as a builtin
-try:
- set
-except NameError:
- from sets import Set as set
-
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
-
from django.db import models, DEFAULT_DB_ALIAS
class Article(models.Model):
View
5 tests/modeltests/model_formsets/models.py
@@ -2,11 +2,6 @@
from django import forms
from django.db import models
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
-
class Author(models.Model):
name = models.CharField(max_length=100)
View
5 tests/modeltests/or_lookups/models.py
@@ -8,11 +8,6 @@
clauses using the variable ``django.db.models.Q`` (or any object with an
``add_to_query`` method).
"""
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
from django.db import models
View
6 tests/modeltests/serializers/models.py
@@ -6,11 +6,7 @@
``QuerySet`` objects to and from "flat" data (i.e. strings).
"""
-try:
- from decimal import Decimal
-except ImportError:
- from django.utils._decimal import Decimal # Python 2.3 fallback
-
+from decimal import Decimal
from django.db import models
class Category(models.Model):
View
5 tests/regressiontests/admin_scripts/management/commands/app_command.py
@@ -1,9 +1,4 @@
from django.core.management.base import AppCommand
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
class Command(AppCommand):
help = 'Test Application-based commands'
View
5 tests/regressiontests/admin_scripts/management/commands/base_command.py
@@ -1,10 +1,5 @@
from django.core.management.base import BaseCommand
from optparse import make_option
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
View
5 tests/regressiontests/admin_scripts/management/commands/label_command.py
@@ -1,9 +1,4 @@
from django.core.management.base import LabelCommand
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
class Command(LabelCommand):
help = "Test Label-based commands"
View
5 tests/regressiontests/admin_scripts/management/commands/noargs_command.py
@@ -1,9 +1,4 @@
from django.core.management.base import NoArgsCommand
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
class Command(NoArgsCommand):
help = "Test No-args commands"
View
5 tests/regressiontests/aggregation_regress/models.py
@@ -4,11 +4,6 @@
from django.db import connection, models, DEFAULT_DB_ALIAS
from django.conf import settings
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted # For Python 2.3
-
class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
View
2  tests/regressiontests/decorators/tests.py
@@ -3,7 +3,7 @@
try:
from functools import wraps
except ImportError:
- from django.utils.functional import wraps # Python 2.3, 2.4 fallback.
+ from django.utils.functional import wraps # Python 2.4 fallback.
from django.http import HttpResponse, HttpRequest
from django.utils.functional import allow_lazy, lazy, memoize
View
6 tests/regressiontests/defaultfilters/tests.py
@@ -580,12 +580,6 @@
from django.template.defaultfilters import *
import datetime
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
-
if __name__ == '__main__':
import doctest
doctest.testmod()
View
5 tests/regressiontests/forms/extra.py
@@ -5,10 +5,7 @@
>>> import datetime
>>> import time
>>> import re
->>> try:
-... from decimal import Decimal
-... except ImportError:
-... from django.utils._decimal import Decimal
+>>> from decimal import Decimal
###############
# Extra stuff #
View
6 tests/regressiontests/forms/fields.py
@@ -28,6 +28,7 @@
import time
import re
import os
+from decimal import Decimal
from unittest import TestCase
@@ -35,11 +36,6 @@
from django.forms import *
from django.forms.widgets import RadioFieldRenderer
-try:
- from decimal import Decimal
-except ImportError:
- from django.utils._decimal import Decimal
-
def fix_os_paths(x):
if isinstance(x, basestring):
View
5 tests/regressiontests/forms/forms.py
@@ -5,10 +5,7 @@
>>> import datetime
>>> import time
>>> import re
->>> try:
-... from decimal import Decimal
-... except ImportError:
-... from django.utils._decimal import Decimal
+>>> from decimal import Decimal
#########
# Forms #
View
5 tests/regressiontests/forms/widgets.py
@@ -7,10 +7,7 @@
>>> import datetime
>>> import time
>>> import re
->>> try:
-... from decimal import Decimal
-... except ImportError:
-... from django.utils._decimal import Decimal
+>>> from decimal import Decimal
>>> from django.utils.translation import activate, deactivate
>>> from django.conf import settings
View
5 tests/regressiontests/model_fields/models.py
@@ -1,11 +1,6 @@
import os
import tempfile
-try:
- import decimal
-except ImportError:
- from django.utils import _decimal as decimal # Python 2.3 fallback
-
# Try to import PIL in either of the two ways it can end up installed.
# Checking for the existence of Image is enough for CPython, but for PyPy,
# you need to check for the underlying modules.
View
7 tests/regressiontests/model_fields/tests.py
@@ -1,5 +1,6 @@
import datetime
import unittest
+from decimal import Decimal
import django.test
from django import forms
@@ -8,12 +9,6 @@
from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel
-try:
- from decimal import Decimal
-except ImportError:
- from django.utils._decimal import Decimal
-
-
# If PIL available, do these tests.
if Image:
from imagefield import \
View
6 tests/regressiontests/model_inheritance_regress/models.py
@@ -6,12 +6,6 @@
from django.db import models
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
-
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
View
12 tests/regressiontests/queries/models.py
@@ -12,12 +12,6 @@
from django.db.models import Count
from django.db.models.query import Q, ITER_CHUNK_SIZE, EmptyQuerySet
-# Python 2.3 doesn't have sorted()
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted
-
class DumbCategory(models.Model):
pass
@@ -1279,12 +1273,12 @@ def __unicode__(self):
"""}
-# In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__
+# In Python 2.6 beta releases, exceptions raised in __len__
# are swallowed (Python issue 1242657), so these cases return an empty list,
# rather than raising an exception. Not a lot we can do about that,
# unfortunately, due to the way Python handles list() calls internally. Thus,
-# we skip the tests for Python 2.3 and 2.6.
-if (2, 4) <= sys.version_info < (2, 6):
+# we skip the tests for Python 2.6.
+if sys.version_info < (2, 6):
__test__["API_TESTS"] += """
# If you're not careful, it's possible to introduce infinite loops via default
# ordering on foreign keys in a cycle. We detect that.
View
15 tests/regressiontests/utils/itercompat.py
@@ -1,15 +0,0 @@
-"""
-# Tests of the utils itercompat library.
-
->>> from django.utils.itercompat import sorted as compat_sorted
-
-# Check the replacement version of sorted
->>> x = [5,1,4,2,3]
->>> y = compat_sorted(x)
->>> print y
-[1, 2, 3, 4, 5]
-
->>> print x
-[5, 1, 4, 2, 3]
-
-"""
View
9 tests/regressiontests/utils/tests.py
@@ -10,25 +10,16 @@
import timesince
import datastructures
import datetime_safe
-import itercompat
import tzinfo
from decorators import DecoratorFromMiddlewareTests
from functional import FunctionalTestCase
-# We need this because "datastructures" uses sorted() and the tests are run in
-# the scope of this module.
-try:
- sorted
-except NameError:
- from django.utils.itercompat import sorted # For Python 2.3
-
# Extra tests
__test__ = {
'timesince': timesince,
'datastructures': datastructures,
'datetime_safe': datetime_safe,
- 'itercompat': itercompat,
'tzinfo': tzinfo,
}
View
6 tests/runtests.py
@@ -5,12 +5,6 @@
import django.contrib as contrib
-try:
- set
-except NameError:
- from sets import Set as set # For Python 2.3
-
-
CONTRIB_DIR_NAME = 'django.contrib'
MODEL_TESTS_DIR_NAME = 'modeltests'
REGRESSION_TESTS_DIR_NAME = 'regressiontests'
Please sign in to comment.
Something went wrong with that request. Please try again.