Permalink
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...
1 parent 7202eb8 commit 5211f48ae3cc0d87a260dbf5c3ab8bdae664c4b6 @freakboy3742 freakboy3742 committed May 4, 2010
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
@@ -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):
"""
@@ -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
@@ -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'
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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()
@@ -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):
@@ -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):
"""
@@ -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)
@@ -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
@@ -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."
@@ -3,18 +3,14 @@
"""
import datetime
+import decimal
from StringIO import StringIO
from django.core.serializers.python import Serializer as PythonSerializer
from django.core.serializers.python import Deserializer as PythonDeserializer
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.
@@ -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.
@@ -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
@@ -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'
@@ -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.
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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',
@@ -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
@@ -2,15 +2,14 @@
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
from django.template import get_library, Library, InvalidTemplateLibrary
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()
@@ -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.
Oops, something went wrong. Retry.

0 comments on commit 5211f48

Please sign in to comment.