Ticket #11753: ticket11753.diff

File ticket11753.diff, 12.7 KB (added by Jeremy Dunck, 15 years ago)

OK, here's an updated patch, still using copycompat, but just shimming in the FunctionType dispatch.

  • django/contrib/admin/widgets.py

    diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
    index fb5acb5..f0ecb38 100644
    a b  
    22Form Widget classes specific to the Django admin site.
    33"""
    44
    5 import copy
     5import django.utils.copycompat as copy
    66
    77from django import forms
    88from django.forms.widgets import RadioFieldRenderer
  • django/contrib/gis/geos/tests/test_geos.py

    diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
    index 440075d..4f2e33f 100644
    a b class GEOSTest(unittest.TestCase):  
    821821
    822822    def test22_copy(self):
    823823        "Testing use with the Python `copy` module."
    824         import copy
     824        import django.utils.copycompat as copy
    825825        poly = GEOSGeometry('POLYGON((0 0, 0 23, 23 23, 23 0, 0 0), (5 5, 5 10, 10 10, 10 5, 5 5))')
    826826        cpy1 = copy.copy(poly)
    827827        cpy2 = copy.deepcopy(poly)
  • django/contrib/gis/geos/tests/test_geos_mutation.py

    diff --git a/django/contrib/gis/geos/tests/test_geos_mutation.py b/django/contrib/gis/geos/tests/test_geos_mutation.py
    index 260a468..28f484d 100644
    a b  
    22# Modified from original contribution by Aryeh Leib Taurog, which was
    33# released under the New BSD license.
    44import unittest
     5
     6import django.utils.copycompat as copy
     7
    58from django.contrib.gis.geos import *
    69from django.contrib.gis.geos.error import GEOSIndexError
    7 import copy
    810
    911def getItem(o,i): return o[i]
    1012def delItem(o,i): del o[i]
  • django/contrib/gis/tests/layermap/tests.py

    diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py
    index b17e7b9..ed5e011 100644
    a b  
    11import os, unittest
    2 from copy import copy
    32from decimal import Decimal
    43from models import City, County, CountyFeat, Interstate, ICity1, ICity2, State, city_mapping, co_mapping, cofeat_mapping, inter_mapping
    54from django.contrib.gis.db.backend import SpatialBackend
    65from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal, MissingForeignKey
    76from django.contrib.gis.gdal import DataSource
     7from django.utils.copycompat import copy
    88
    99shp_path = os.path.dirname(__file__)
    1010city_shp = os.path.join(shp_path, '../data/cities/cities.shp')
  • django/db/models/base.py

    diff --git a/django/db/models/base.py b/django/db/models/base.py
    index 47c1772..5b727a0 100644
    a b  
    1 import copy
    21import types
    32import sys
    43import os
    from django.db.models.options import Options  
    1312from django.db import connection, transaction, DatabaseError
    1413from django.db.models import signals
    1514from django.db.models.loading import register_models, get_model
     15import django.utils.copycompat as copy
    1616from django.utils.functional import curry
    1717from django.utils.encoding import smart_str, force_unicode, smart_unicode
    1818from django.conf import settings
  • django/db/models/expressions.py

    diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
    index e54aaba..68abf9d 100644
    a b  
    1 from copy import deepcopy
    21from datetime import datetime
    32
    43from django.utils import tree
     4from django.utils.copycompat import deepcopy
    55
    66class ExpressionNode(tree.Node):
    77    """
  • django/db/models/fields/__init__.py

    diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
    index b5fd30e..ac43f2b 100644
    a b  
    1 import copy
    21import datetime
     2import decimal
    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
     6
     7import django.utils.copycompat as copy
    108
    119from django.db import connection
    1210from django.db.models import signals
  • django/db/models/fields/files.py

    diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
    index e6497f0..97cb4dc 100644
    a b  
    1 import copy
    21import datetime
    32import os
    43
     4import django.utils.copycompat as copy
     5
    56from django.conf import settings
    67from django.db.models.fields import Field
    78from django.core.files.base import File, ContentFile
  • django/db/models/manager.py

    diff --git a/django/db/models/manager.py b/django/db/models/manager.py
    index 7487fa0..2eeb98b 100644
    a b  
    1 import copy
     1import django.utils.copycompat as copy
    22from django.db.models.query import QuerySet, EmptyQuerySet, insert_query
    33from django.db.models import signals
    44from django.db.models.fields import FieldDoesNotExist
  • django/db/models/query.py

    diff --git a/django/db/models/query.py b/django/db/models/query.py
    index 6a16ce1..9cc7659 100644
    a b  
    22The main QuerySet implementation. This provides the public API for the ORM.
    33"""
    44
    5 from copy import deepcopy
    65from django.db import connection, transaction, IntegrityError
    76from django.db.models.aggregates import Aggregate
    87from django.db.models.fields import DateField
    98from django.db.models.query_utils import Q, select_related_descend, CollectedObjects, CyclicDependency, deferred_class_factory
    109from django.db.models import signals, sql
     10from django.utils.copycompat import deepcopy
    1111
    1212# Used to control how many objects are worked with at once in some cases (e.g.
    1313# when deleting objects).
  • django/db/models/query_utils.py

    diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
    index 6a6b690..c5cb336 100644
    a b circular import difficulties.  
    77"""
    88
    99import weakref
    10 from copy import deepcopy
     10from django.utils.copycompat import deepcopy
    1111
    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 
    2015
    2116class CyclicDependency(Exception):
    2217    """
  • django/db/models/sql/query.py

    diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
    index 7bc45cb..f3e24ed 100644
    a b databases). The abstraction barrier only works one way: this module has to know  
    77all about the internals of models in order to get the information it needs.
    88"""
    99
    10 from copy import deepcopy
     10from django.utils.copycompat import deepcopy
    1111from django.utils.tree import Node
    1212from django.utils.datastructures import SortedDict
    1313from django.utils.encoding import force_unicode
  • django/forms/fields.py

    diff --git a/django/forms/fields.py b/django/forms/fields.py
    index 0aef355..c0ee2f0 100644
    a b  
    22Field classes.
    33"""
    44
    5 import copy
    65import datetime
    76import os
    87import re
    98import time
    109import urlparse
     10from decimal import Decimal, DecimalException
    1111try:
    1212    from cStringIO import StringIO
    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
     17import django.utils.copycompat as copy
    2718from django.utils.translation import ugettext_lazy as _
    2819from django.utils.encoding import smart_unicode, smart_str
    2920
  • django/forms/forms.py

    diff --git a/django/forms/forms.py b/django/forms/forms.py
    index e854de8..7f6fa51 100644
    a b  
    22Form classes
    33"""
    44
    5 from copy import deepcopy
    6 
     5from django.utils.copycompat import deepcopy
    76from django.utils.datastructures import SortedDict
    87from django.utils.html import conditional_escape
    98from django.utils.encoding import StrAndUnicode, smart_unicode, force_unicode
  • django/forms/widgets.py

    diff --git a/django/forms/widgets.py b/django/forms/widgets.py
    index b1d2cb7..d59e634 100644
    a b  
    22HTML Widget classes
    33"""
    44
    5 try:
    6     set
    7 except NameError:
    8     from sets import Set as set   # Python 2.3 fallback
    9 
    10 import copy
     5import django.utils.copycompat as copy
    116from itertools import chain
    127from django.conf import settings
    138from django.utils.datastructures import MultiValueDict, MergeDict
  • django/http/__init__.py

    diff --git a/django/http/__init__.py b/django/http/__init__.py
    index 446659b..7b0c469 100644
    a b class QueryDict(MultiValueDict):  
    183183        return result
    184184
    185185    def __deepcopy__(self, memo):
    186         import copy
     186        import django.utils.copycompat as copy
    187187        result = self.__class__('', mutable=True)
    188188        memo[id(self)] = result
    189189        for key, value in dict.items(self):
  • django/utils/_decimal.py

    diff --git a/django/utils/_decimal.py b/django/utils/_decimal.py
    index 677d26b..2801046 100644
    a b __all__ = [  
    134134    'setcontext', 'getcontext'
    135135]
    136136
    137 import copy as _copy
     137import django.utils.copycompat as _copy
    138138
    139139#Rounding
    140140ROUND_DOWN = 'ROUND_DOWN'
  • new file django/utils/copycompat.py

    diff --git a/django/utils/copycompat.py b/django/utils/copycompat.py
    new file mode 100644
    index 0000000..33eddf5
    - +  
     1from copy import *
     2import copy as _copy #to get at private variables
     3import types
     4
     5#Fix Python 2.4's lack of user function copying
     6if (hasattr(_copy, '_deepcopy_dispatch') and
     7    not types.FunctionType in _copy._deepcopy_dispatch):
     8    _copy._deepcopy_dispatch[types.FunctionType] = _copy._deepcopy_atomic
  • django/utils/datastructures.py

    diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
    index 2b586d7..06cf6c6 100644
    a b  
    1 from copy import deepcopy
     1from django.utils.copycompat import deepcopy
    22
    33
    44class MergeDict(object):
    class MultiValueDict(dict):  
    214214        return self.__class__(super(MultiValueDict, self).items())
    215215
    216216    def __deepcopy__(self, memo=None):
    217         import copy
     217        import django.utils.copycompat as copy
    218218        if memo is None:
    219219            memo = {}
    220220        result = self.__class__()
  • django/utils/functional.py

    diff --git a/django/utils/functional.py b/django/utils/functional.py
    index 823cda4..43b7ab1 100644
    a b class SimpleLazyObject(LazyObject):  
    335335            memo[id(self)] = result
    336336            return result
    337337        else:
    338             import copy
    339             return copy.deepcopy(self._wrapped, memo)
     338            # Changed to use deepcopy from copycompat, instead of copy
     339            # For Python 2.4.
     340            from django.utils.copycompat import deepcopy
     341            return deepcopy(self._wrapped, memo)
    340342
    341343    # Need to pretend to be the wrapped class, for the sake of objects that care
    342344    # about this (especially in equality tests)
  • django/utils/tree.py

    diff --git a/django/utils/tree.py b/django/utils/tree.py
    index a9028b8..a6cfec2 100644
    a b A class for storing a tree graph. Primarily used for filter constructs in the  
    33ORM.
    44"""
    55
    6 from copy import deepcopy
     6from django.utils.copycompat import deepcopy
    77
    88class Node(object):
    99    """
  • tests/regressiontests/dispatch/tests/test_dispatcher.py

    diff --git a/tests/regressiontests/dispatch/tests/test_dispatcher.py b/tests/regressiontests/dispatch/tests/test_dispatcher.py
    index adf7603..ad3a05f 100644
    a b  
    11from django.dispatch import Signal
    22import unittest
    3 import copy
    43import sys
    54import gc
     5import django.utils.copycompat as copy
    66
    77if sys.platform.startswith('java'):
    88    def garbage_collect():
  • tests/regressiontests/extra_regress/models.py

    diff --git a/tests/regressiontests/extra_regress/models.py b/tests/regressiontests/extra_regress/models.py
    index 5d22d6c..76eb549 100644
    a b  
    1 import copy
    21import datetime
    32
     3import django.utils.copycompat as copy
     4
    45from django.contrib.auth.models import User
    56from django.db import models
    67from django.db.models.query import Q
  • tests/regressiontests/utils/tests.py

    diff --git a/tests/regressiontests/utils/tests.py b/tests/regressiontests/utils/tests.py
    index a7a6e4c..6258b81 100644
    a b class TestUtilsSimpleLazyObject(TestCase):  
    220220        self.assertEqual(_ComplexObject, SimpleLazyObject(complex_object).__class__)
    221221
    222222    def test_deepcopy(self):
    223         import copy
     223        import django.utils.copycompat as copy
    224224        # Check that we *can* do deep copy, and that it returns the right
    225225        # objects.
    226226
Back to Top