Package: python-django-registration
Version: 0.7-2
Severity: normal
Tags: patch

Using django-registration models or running its tests
with python 2.6+ emits deprecation warning like the following:

> /usr/lib/pymodules/python2.6/registration/models.py:4:
> DeprecationWarning: the sha module is deprecated; use the hashlib module
> instead
>   import sha



-- System Information:
Debian Release: squeeze/sid
  APT prefers karmic-updates
  APT policy: (990, 'karmic-updates'), (990, 'karmic-security'), (990, 
'karmic'), (650, 'lucid')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.31-21-generic (SMP w/4 CPU cores)
Locale: LANG=uk_UA.UTF-8, LC_CTYPE=uk_UA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages python-django-registration depends on:
ii  python                    2.6.4-0ubuntu1 An interactive high-level object-o
ii  python-django             1.1.1-1ubuntu1 High-level Python web development 
ii  python-support            1.0.3ubuntu1   automated rebuilding support for P

python-django-registration recommends no packages.

python-django-registration suggests no packages.

-- no debconf information
--- Begin Message ---
Use django.util.hashcompat to avoid
deprecation warnings for SHA on Python 2.6+

Signed-off-by: Ihor Kaharlichenko <ce...@mifprojects.com>

---
 registration/models.py |    6 +++---
 registration/tests.py  |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/registration/models.py b/registration/models.py
index d13a07a..b5bf28b 100644
--- a/registration/models.py
+++ b/registration/models.py
@@ -1,11 +1,11 @@
 import datetime
 import random
 import re
-import sha
 
 from django.conf import settings
 from django.db import models
 from django.template.loader import render_to_string
+from django.utils.hashcompat import sha_constructor
 from django.utils.translation import ugettext_lazy as _
 from django.contrib.auth.models import User
 from django.contrib.sites.models import Site
@@ -137,8 +137,8 @@ class RegistrationManager(models.Manager):
         username and a random salt.
         
         """
-        salt = sha.new(str(random.random())).hexdigest()[:5]
-        activation_key = sha.new(salt+user.username).hexdigest()
+        salt = sha_constructor(str(random.random())).hexdigest()[:5]
+        activation_key = sha_constructor(salt+user.username).hexdigest()
         return self.create(user=user,
                            activation_key=activation_key)
         
diff --git a/registration/tests.py b/registration/tests.py
index 96a24fa..098a286 100644
--- a/registration/tests.py
+++ b/registration/tests.py
@@ -20,7 +20,6 @@ getting django-registration running in the default setup, to 
wit:
 """
 
 import datetime
-import sha
 
 from django.conf import settings
 from django.contrib.auth.models import User
@@ -28,6 +27,7 @@ from django.core import mail
 from django.core import management
 from django.core.urlresolvers import reverse
 from django.test import TestCase
+from django.utils.hashcompat import sha_constructor
 
 from registration import forms
 from registration.models import RegistrationProfile
@@ -103,7 +103,7 @@ class RegistrationModelTests(RegistrationTestCase):
         self.failIf(RegistrationProfile.objects.activate_user('foo'))
         
         # Activating from a key that doesn't exist returns False.
-        
self.failIf(RegistrationProfile.objects.activate_user(sha.new('foo').hexdigest()))
+        
self.failIf(RegistrationProfile.objects.activate_user(sha_constructor('foo').hexdigest()))
 
     def test_account_expiration_condition(self):
         """
@@ -314,5 +314,5 @@ class RegistrationViewTests(RegistrationTestCase):
 
         # Nonexistent key sets the account to False.
         response = self.client.get(reverse('registration_activate',
-                                           kwargs={ 'activation_key': 
sha.new('foo').hexdigest() }))
+                                           kwargs={ 'activation_key': 
sha_constructor('foo').hexdigest() }))
         self.failIf(response.context['account'])
-- 
tg: (0c68f39..) fix/sha_warning (depends on: master)

--- End Message ---

Reply via email to