Browse files

Re-added a few compatibility modules that were removed in r15927 to l…

…ower the impact on 3rd party apps.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
jezdez committed Mar 30, 2011
1 parent 99b2728 commit 37ed6f26812e960a034cb1312257bf7436bad965
Showing with 67 additions and 0 deletions.
  1. +18 −0 django/utils/
  2. +24 −0 django/utils/
  3. +17 −0 django/utils/
  4. +8 −0 docs/internals/deprecation.txt
@@ -0,0 +1,18 @@
Fixes Python 2.4's failure to deepcopy unbound functions.
import copy
import types
import warnings
warnings.warn("django.utils.copycompat is deprecated; use the native copy module instead",
# 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 *
@@ -0,0 +1,24 @@
The md5 and sha modules are deprecated since Python 2.5, replaced by the
hashlib module containing both hash algorithms. Here, we provide a common
interface to the md5 and sha constructors, depending on system version.
import sys
import warnings
warnings.warn("django.utils.hashcompat is deprecated; use hashlib instead",
if sys.version_info >= (2, 5):
import hashlib
md5_constructor = hashlib.md5
md5_hmac = md5_constructor
sha_constructor = hashlib.sha1
sha_hmac = sha_constructor
import md5
md5_constructor =
md5_hmac = md5
import sha
sha_constructor =
sha_hmac = sha
@@ -5,6 +5,7 @@
import itertools
import warnings
# Fallback for Python 2.4, Python 2.5
def product(*args, **kwds):
@@ -31,3 +32,19 @@ def is_iterable(x):
return False
return True
def all(iterable):
warnings.warn("django.utils.itercompat.all is deprecated; use the native version instead",
for item in iterable:
if not item:
return False
return True
def any(iterable):
warnings.warn("django.utils.itercompat.any is deprecated; use the native version instead",
for item in iterable:
if item:
return True
return False
@@ -171,6 +171,14 @@ their deprecation, as per the :ref:`Django deprecation policy
with a trailing slash to ensure there is a consistent way to
combine paths in templates.
* 1.6
* The compatibility modules ``django.utils.copycompat`` and
``django.utils.hashcompat`` as well as the functions
``django.utils.itercompat.all`` and ``django.utils.itercompat.any``
have been deprecated since the 1.4 release. The native versions
should be used instead.
* 2.0
* ``django.views.defaults.shortcut()``. This function has been moved
to ``django.contrib.contenttypes.views.shortcut()`` as part of the

0 comments on commit 37ed6f2

Please sign in to comment.