diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-12-17 22:06:41 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-12-17 22:06:41 +0000 |
| commit | 574eafe4c08c4a63876e199e0f2657868c8d0718 (patch) | |
| tree | e5c22d5015aa9b37e7a09b8d87ab69e9fde68f0b /django/utils | |
| parent | 3bd849062c57d297f3b6f7cb12e4644ce19c52f8 (diff) | |
Fixed #11753 - Q objects with callables no longer explode on Python 2.4. Thanks, Jeremy Dunck.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11901 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/_decimal.py | 2 | ||||
| -rw-r--r-- | django/utils/copycompat.py | 14 | ||||
| -rw-r--r-- | django/utils/datastructures.py | 4 | ||||
| -rw-r--r-- | django/utils/functional.py | 6 | ||||
| -rw-r--r-- | django/utils/tree.py | 2 |
5 files changed, 22 insertions, 6 deletions
diff --git a/django/utils/_decimal.py b/django/utils/_decimal.py index 677d26bb32..2801046cf1 100644 --- a/django/utils/_decimal.py +++ b/django/utils/_decimal.py @@ -134,7 +134,7 @@ __all__ = [ 'setcontext', 'getcontext' ] -import copy as _copy +import django.utils.copycompat as _copy #Rounding ROUND_DOWN = 'ROUND_DOWN' diff --git a/django/utils/copycompat.py b/django/utils/copycompat.py new file mode 100644 index 0000000000..22b3cfbef7 --- /dev/null +++ b/django/utils/copycompat.py @@ -0,0 +1,14 @@ +""" +Fixes Python 2.4's failure to deepcopy unbound functions. +""" + +import copy +import types + +# Monkeypatch copy's deepcopy registry to handle functions correctly. +if (hasattr(copy, '_deepcopy_dispatch') and types.FunctionType not in copy._deepcopy_dispatch): + copy._deepcopy_dispatch[types.FunctionType] = copy._deepcopy_atomic + +# Pose as the copy module now. +del copy, types +from copy import * diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 2b586d7efe..06cf6c6b75 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -1,4 +1,4 @@ -from copy import deepcopy +from django.utils.copycompat import deepcopy class MergeDict(object): @@ -214,7 +214,7 @@ class MultiValueDict(dict): return self.__class__(super(MultiValueDict, self).items()) def __deepcopy__(self, memo=None): - import copy + import django.utils.copycompat as copy if memo is None: memo = {} result = self.__class__() diff --git a/django/utils/functional.py b/django/utils/functional.py index 823cda4587..43b7ab1437 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -335,8 +335,10 @@ class SimpleLazyObject(LazyObject): memo[id(self)] = result return result else: - import copy - return copy.deepcopy(self._wrapped, memo) + # Changed to use deepcopy from copycompat, instead of copy + # For Python 2.4. + from django.utils.copycompat import deepcopy + return deepcopy(self._wrapped, memo) # Need to pretend to be the wrapped class, for the sake of objects that care # about this (especially in equality tests) diff --git a/django/utils/tree.py b/django/utils/tree.py index a9028b834b..a6cfec27ad 100644 --- a/django/utils/tree.py +++ b/django/utils/tree.py @@ -3,7 +3,7 @@ A class for storing a tree graph. Primarily used for filter constructs in the ORM. """ -from copy import deepcopy +from django.utils.copycompat import deepcopy class Node(object): """ |
