Ticket #4607: fallback_try_except.patch

File fallback_try_except.patch, 6.2 KB (added by Chris Beaven, 17 years ago)
  • django/contrib/admin/views/main.py

     
    1414from django.utils.text import capfirst, get_text_list
    1515import operator
    1616
     17try:
     18    set
     19except NameError:
     20    from sets import Set as set   # Python 2.3 fallback
     21
    1722from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, DELETION
    1823if not LogEntry._meta.installed:
    1924    raise ImproperlyConfigured, "You'll need to put 'django.contrib.admin' in your INSTALLED_APPS setting before you can use the admin application."
     
    489494                perms_needed.add(related.opts.verbose_name)
    490495
    491496def delete_stage(request, app_label, model_name, object_id):
    492     import sets
    493497    model = models.get_model(app_label, model_name)
    494498    object_id = unquote(object_id)
    495499    if model is None:
     
    502506    # Populate deleted_objects, a data structure of all related objects that
    503507    # will also be deleted.
    504508    deleted_objects = ['%s: <a href="../../%s/">%s</a>' % (capfirst(opts.verbose_name), object_id, escape(str(obj))), []]
    505     perms_needed = sets.Set()
     509    perms_needed = set()
    506510    _get_deleted_objects(deleted_objects, perms_needed, request.user, obj, opts, 1)
    507511
    508512    if request.POST: # The user has already confirmed the deletion.
  • django/contrib/auth/models.py

     
    55from django.utils.translation import gettext_lazy as _
    66import datetime
    77
     8try:
     9    set
     10except NameError:
     11    from sets import Set as set   # Python 2.3 fallback
     12
    813def check_password(raw_password, enc_password):
    914    """
    1015    Returns a boolean of whether the raw_password was correct. Handles
     
    175180    def get_group_permissions(self):
    176181        "Returns a list of permission strings that this user has through his/her groups."
    177182        if not hasattr(self, '_group_perm_cache'):
    178             import sets
    179183            cursor = connection.cursor()
    180184            # The SQL below works out to the following, after DB quoting:
    181185            # cursor.execute("""
     
    200204                backend.quote_name('id'), backend.quote_name('content_type_id'),
    201205                backend.quote_name('user_id'),)
    202206            cursor.execute(sql, [self.id])
    203             self._group_perm_cache = sets.Set(["%s.%s" % (row[0], row[1]) for row in cursor.fetchall()])
     207            self._group_perm_cache = set(["%s.%s" % (row[0], row[1]) for row in cursor.fetchall()])
    204208        return self._group_perm_cache
    205209
    206210    def get_all_permissions(self):
    207211        if not hasattr(self, '_perm_cache'):
    208212            import sets
    209             self._perm_cache = sets.Set(["%s.%s" % (p.content_type.app_label, p.codename) for p in self.user_permissions.select_related()])
     213            self._perm_cache = set(["%s.%s" % (p.content_type.app_label, p.codename) for p in self.user_permissions.select_related()])
    210214            self._perm_cache.update(self.get_group_permissions())
    211215        return self._perm_cache
    212216
  • django/core/management.py

     
    77from django.utils import termcolors
    88import os, re, shutil, sys, textwrap
    99
    10 # For Python 2.3
    11 if not hasattr(__builtins__, 'set'):
    12     from sets import Set as set
     10try:
     11    set
     12except NameError:
     13    from sets import Set as set   # Python 2.3 fallback
    1314
    1415# For backwards compatibility: get_version() used to be in this module.
    1516get_version = django.get_version
  • django/db/models/fields/related.py

     
    1010from django import newforms as forms
    1111from django.dispatch import dispatcher
    1212
    13 # For Python 2.3
    14 if not hasattr(__builtins__, 'set'):
    15     from sets import Set as set
     13try:
     14    set
     15except NameError:
     16    from sets import Set as set   # Python 2.3 fallback
    1617
    1718# Values for Relation.edit_inline.
    1819TABULAR, STACKED = 1, 2
  • django/db/models/query.py

     
    77import operator
    88import re
    99
    10 # For Python 2.3
    11 if not hasattr(__builtins__, 'set'):
    12     from sets import Set as set
     10try:
     11    set
     12except NameError:
     13    from sets import Set as set   # Python 2.3 fallback
    1314
    1415# The string constant used to separate query parts
    1516LOOKUP_SEPARATOR = '__'
  • django/newforms/fields.py

     
    2727EMPTY_VALUES = (None, '')
    2828
    2929try:
    30     set # Only available in Python 2.4+
     30    set
    3131except NameError:
    32     from sets import Set as set # Python 2.3 fallback
     32    from sets import Set as set   # Python 2.3 fallback
    3333
    3434try:
    3535    from decimal import Decimal
  • django/newforms/widgets.py

     
    33"""
    44
    55try:
    6     set # Only available in Python 2.4+
     6    set
    77except NameError:
    8     from sets import Set as set # Python 2.3 fallback
     8    from sets import Set as set   # Python 2.3 fallback
     9
    910from itertools import chain
    1011
    1112from django.utils.datastructures import MultiValueDict
  • django/template/defaulttags.py

     
    88import sys
    99import re
    1010
    11 if not hasattr(__builtins__, 'reversed'):
    12     # For Python 2.3.
     11try:
     12    reversed
     13except NameError:
     14    # Python 2.3 fallback.
    1315    # From http://www.python.org/doc/current/tut/node11.html
    1416    def reversed(data):
    1517        for index in xrange(len(data)-1, -1, -1):
Back to Top