-
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index fb5acb5..f0ecb38 100644
|
a
|
b
|
|
| 2 | 2 | Form Widget classes specific to the Django admin site. |
| 3 | 3 | """ |
| 4 | 4 | |
| 5 | | import copy |
| | 5 | import django.utils.copycompat as copy |
| 6 | 6 | |
| 7 | 7 | from django import forms |
| 8 | 8 | from django.forms.widgets import RadioFieldRenderer |
-
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):
|
| 821 | 821 | |
| 822 | 822 | def test22_copy(self): |
| 823 | 823 | "Testing use with the Python `copy` module." |
| 824 | | import copy |
| | 824 | import django.utils.copycompat as copy |
| 825 | 825 | poly = GEOSGeometry('POLYGON((0 0, 0 23, 23 23, 23 0, 0 0), (5 5, 5 10, 10 10, 10 5, 5 5))') |
| 826 | 826 | cpy1 = copy.copy(poly) |
| 827 | 827 | cpy2 = copy.deepcopy(poly) |
-
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
|
|
| 2 | 2 | # Modified from original contribution by Aryeh Leib Taurog, which was |
| 3 | 3 | # released under the New BSD license. |
| 4 | 4 | import unittest |
| | 5 | |
| | 6 | import django.utils.copycompat as copy |
| | 7 | |
| 5 | 8 | from django.contrib.gis.geos import * |
| 6 | 9 | from django.contrib.gis.geos.error import GEOSIndexError |
| 7 | | import copy |
| 8 | 10 | |
| 9 | 11 | def getItem(o,i): return o[i] |
| 10 | 12 | def delItem(o,i): del o[i] |
-
diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py
index b17e7b9..ed5e011 100644
|
a
|
b
|
|
| 1 | 1 | import os, unittest |
| 2 | | from copy import copy |
| 3 | 2 | from decimal import Decimal |
| 4 | 3 | from models import City, County, CountyFeat, Interstate, ICity1, ICity2, State, city_mapping, co_mapping, cofeat_mapping, inter_mapping |
| 5 | 4 | from django.contrib.gis.db.backend import SpatialBackend |
| 6 | 5 | from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal, MissingForeignKey |
| 7 | 6 | from django.contrib.gis.gdal import DataSource |
| | 7 | from django.utils.copycompat import copy |
| 8 | 8 | |
| 9 | 9 | shp_path = os.path.dirname(__file__) |
| 10 | 10 | city_shp = os.path.join(shp_path, '../data/cities/cities.shp') |
-
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 47c1772..5b727a0 100644
|
a
|
b
|
|
| 1 | | import copy |
| 2 | 1 | import types |
| 3 | 2 | import sys |
| 4 | 3 | import os |
| … |
… |
from django.db.models.options import Options
|
| 13 | 12 | from django.db import connection, transaction, DatabaseError |
| 14 | 13 | from django.db.models import signals |
| 15 | 14 | from django.db.models.loading import register_models, get_model |
| | 15 | import django.utils.copycompat as copy |
| 16 | 16 | from django.utils.functional import curry |
| 17 | 17 | from django.utils.encoding import smart_str, force_unicode, smart_unicode |
| 18 | 18 | from django.conf import settings |
-
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 |
| 2 | 1 | from datetime import datetime |
| 3 | 2 | |
| 4 | 3 | from django.utils import tree |
| | 4 | from django.utils.copycompat import deepcopy |
| 5 | 5 | |
| 6 | 6 | class ExpressionNode(tree.Node): |
| 7 | 7 | """ |
-
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 |
| 2 | 1 | import datetime |
| | 2 | import decimal |
| 3 | 3 | import os |
| 4 | 4 | import re |
| 5 | 5 | import time |
| 6 | | try: |
| 7 | | import decimal |
| 8 | | except ImportError: |
| 9 | | from django.utils import _decimal as decimal # for Python 2.3 |
| | 6 | |
| | 7 | import django.utils.copycompat as copy |
| 10 | 8 | |
| 11 | 9 | from django.db import connection |
| 12 | 10 | from django.db.models import signals |
-
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 |
| 2 | 1 | import datetime |
| 3 | 2 | import os |
| 4 | 3 | |
| | 4 | import django.utils.copycompat as copy |
| | 5 | |
| 5 | 6 | from django.conf import settings |
| 6 | 7 | from django.db.models.fields import Field |
| 7 | 8 | from django.core.files.base import File, ContentFile |
-
diff --git a/django/db/models/manager.py b/django/db/models/manager.py
index 7487fa0..2eeb98b 100644
|
a
|
b
|
|
| 1 | | import copy |
| | 1 | import django.utils.copycompat as copy |
| 2 | 2 | from django.db.models.query import QuerySet, EmptyQuerySet, insert_query |
| 3 | 3 | from django.db.models import signals |
| 4 | 4 | from django.db.models.fields import FieldDoesNotExist |
-
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 6a16ce1..9cc7659 100644
|
a
|
b
|
|
| 2 | 2 | The main QuerySet implementation. This provides the public API for the ORM. |
| 3 | 3 | """ |
| 4 | 4 | |
| 5 | | from copy import deepcopy |
| 6 | 5 | from django.db import connection, transaction, IntegrityError |
| 7 | 6 | from django.db.models.aggregates import Aggregate |
| 8 | 7 | from django.db.models.fields import DateField |
| 9 | 8 | from django.db.models.query_utils import Q, select_related_descend, CollectedObjects, CyclicDependency, deferred_class_factory |
| 10 | 9 | from django.db.models import signals, sql |
| | 10 | from django.utils.copycompat import deepcopy |
| 11 | 11 | |
| 12 | 12 | # Used to control how many objects are worked with at once in some cases (e.g. |
| 13 | 13 | # when deleting objects). |
-
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.
|
| 7 | 7 | """ |
| 8 | 8 | |
| 9 | 9 | import weakref |
| 10 | | from copy import deepcopy |
| | 10 | from django.utils.copycompat import deepcopy |
| 11 | 11 | |
| 12 | 12 | from django.utils import tree |
| 13 | 13 | from django.utils.datastructures import SortedDict |
| 14 | 14 | |
| 15 | | try: |
| 16 | | sorted |
| 17 | | except NameError: |
| 18 | | from django.utils.itercompat import sorted # For Python 2.3. |
| 19 | | |
| 20 | 15 | |
| 21 | 16 | class CyclicDependency(Exception): |
| 22 | 17 | """ |
-
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
|
| 7 | 7 | all about the internals of models in order to get the information it needs. |
| 8 | 8 | """ |
| 9 | 9 | |
| 10 | | from copy import deepcopy |
| | 10 | from django.utils.copycompat import deepcopy |
| 11 | 11 | from django.utils.tree import Node |
| 12 | 12 | from django.utils.datastructures import SortedDict |
| 13 | 13 | from django.utils.encoding import force_unicode |
-
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 0aef355..c0ee2f0 100644
|
a
|
b
|
|
| 2 | 2 | Field classes. |
| 3 | 3 | """ |
| 4 | 4 | |
| 5 | | import copy |
| 6 | 5 | import datetime |
| 7 | 6 | import os |
| 8 | 7 | import re |
| 9 | 8 | import time |
| 10 | 9 | import urlparse |
| | 10 | from decimal import Decimal, DecimalException |
| 11 | 11 | try: |
| 12 | 12 | from cStringIO import StringIO |
| 13 | 13 | except ImportError: |
| 14 | 14 | from StringIO import StringIO |
| 15 | 15 | |
| 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 | | |
| 26 | 16 | import django.core.exceptions |
| | 17 | import django.utils.copycompat as copy |
| 27 | 18 | from django.utils.translation import ugettext_lazy as _ |
| 28 | 19 | from django.utils.encoding import smart_unicode, smart_str |
| 29 | 20 | |
-
diff --git a/django/forms/forms.py b/django/forms/forms.py
index e854de8..7f6fa51 100644
|
a
|
b
|
|
| 2 | 2 | Form classes |
| 3 | 3 | """ |
| 4 | 4 | |
| 5 | | from copy import deepcopy |
| 6 | | |
| | 5 | from django.utils.copycompat import deepcopy |
| 7 | 6 | from django.utils.datastructures import SortedDict |
| 8 | 7 | from django.utils.html import conditional_escape |
| 9 | 8 | from django.utils.encoding import StrAndUnicode, smart_unicode, force_unicode |
-
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index b1d2cb7..d59e634 100644
|
a
|
b
|
|
| 2 | 2 | HTML Widget classes |
| 3 | 3 | """ |
| 4 | 4 | |
| 5 | | try: |
| 6 | | set |
| 7 | | except NameError: |
| 8 | | from sets import Set as set # Python 2.3 fallback |
| 9 | | |
| 10 | | import copy |
| | 5 | import django.utils.copycompat as copy |
| 11 | 6 | from itertools import chain |
| 12 | 7 | from django.conf import settings |
| 13 | 8 | from django.utils.datastructures import MultiValueDict, MergeDict |
-
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 446659b..7b0c469 100644
|
a
|
b
|
class QueryDict(MultiValueDict):
|
| 183 | 183 | return result |
| 184 | 184 | |
| 185 | 185 | def __deepcopy__(self, memo): |
| 186 | | import copy |
| | 186 | import django.utils.copycompat as copy |
| 187 | 187 | result = self.__class__('', mutable=True) |
| 188 | 188 | memo[id(self)] = result |
| 189 | 189 | for key, value in dict.items(self): |
-
diff --git a/django/utils/_decimal.py b/django/utils/_decimal.py
index 677d26b..2801046 100644
|
a
|
b
|
__all__ = [
|
| 134 | 134 | 'setcontext', 'getcontext' |
| 135 | 135 | ] |
| 136 | 136 | |
| 137 | | import copy as _copy |
| | 137 | import django.utils.copycompat as _copy |
| 138 | 138 | |
| 139 | 139 | #Rounding |
| 140 | 140 | ROUND_DOWN = 'ROUND_DOWN' |
-
diff --git a/django/utils/copycompat.py b/django/utils/copycompat.py
new file mode 100644
index 0000000..33eddf5
|
-
|
+
|
|
| | 1 | from copy import * |
| | 2 | import copy as _copy #to get at private variables |
| | 3 | import types |
| | 4 | |
| | 5 | #Fix Python 2.4's lack of user function copying |
| | 6 | if (hasattr(_copy, '_deepcopy_dispatch') and |
| | 7 | not types.FunctionType in _copy._deepcopy_dispatch): |
| | 8 | _copy._deepcopy_dispatch[types.FunctionType] = _copy._deepcopy_atomic |
-
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index 2b586d7..06cf6c6 100644
|
a
|
b
|
|
| 1 | | from copy import deepcopy |
| | 1 | from django.utils.copycompat import deepcopy |
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | class MergeDict(object): |
| … |
… |
class MultiValueDict(dict):
|
| 214 | 214 | return self.__class__(super(MultiValueDict, self).items()) |
| 215 | 215 | |
| 216 | 216 | def __deepcopy__(self, memo=None): |
| 217 | | import copy |
| | 217 | import django.utils.copycompat as copy |
| 218 | 218 | if memo is None: |
| 219 | 219 | memo = {} |
| 220 | 220 | result = self.__class__() |
-
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 823cda4..43b7ab1 100644
|
a
|
b
|
class SimpleLazyObject(LazyObject):
|
| 335 | 335 | memo[id(self)] = result |
| 336 | 336 | return result |
| 337 | 337 | 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) |
| 340 | 342 | |
| 341 | 343 | # Need to pretend to be the wrapped class, for the sake of objects that care |
| 342 | 344 | # about this (especially in equality tests) |
-
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
|
| 3 | 3 | ORM. |
| 4 | 4 | """ |
| 5 | 5 | |
| 6 | | from copy import deepcopy |
| | 6 | from django.utils.copycompat import deepcopy |
| 7 | 7 | |
| 8 | 8 | class Node(object): |
| 9 | 9 | """ |
-
diff --git a/tests/regressiontests/dispatch/tests/test_dispatcher.py b/tests/regressiontests/dispatch/tests/test_dispatcher.py
index adf7603..ad3a05f 100644
|
a
|
b
|
|
| 1 | 1 | from django.dispatch import Signal |
| 2 | 2 | import unittest |
| 3 | | import copy |
| 4 | 3 | import sys |
| 5 | 4 | import gc |
| | 5 | import django.utils.copycompat as copy |
| 6 | 6 | |
| 7 | 7 | if sys.platform.startswith('java'): |
| 8 | 8 | def garbage_collect(): |
-
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 |
| 2 | 1 | import datetime |
| 3 | 2 | |
| | 3 | import django.utils.copycompat as copy |
| | 4 | |
| 4 | 5 | from django.contrib.auth.models import User |
| 5 | 6 | from django.db import models |
| 6 | 7 | from django.db.models.query import Q |
-
diff --git a/tests/regressiontests/utils/tests.py b/tests/regressiontests/utils/tests.py
index a7a6e4c..6258b81 100644
|
a
|
b
|
class TestUtilsSimpleLazyObject(TestCase):
|
| 220 | 220 | self.assertEqual(_ComplexObject, SimpleLazyObject(complex_object).__class__) |
| 221 | 221 | |
| 222 | 222 | def test_deepcopy(self): |
| 223 | | import copy |
| | 223 | import django.utils.copycompat as copy |
| 224 | 224 | # Check that we *can* do deep copy, and that it returns the right |
| 225 | 225 | # objects. |
| 226 | 226 | |