[Supervisor-checkins] r901 - in supervisor/trunk: . src/supervisor src/supervisor/tests
Mike Naberezny
mike at maintainable.com
Sat Oct 24 15:56:37 EDT 2009
Author: Mike Naberezny <mike at maintainable.com>
Date: Sat Oct 24 15:56:37 2009
New Revision: 901
Log:
Fixed a Python 2.6 deprecation warning on use of the "sha" module.
Modified:
supervisor/trunk/CHANGES.txt
supervisor/trunk/src/supervisor/http.py
supervisor/trunk/src/supervisor/tests/test_http.py
Modified: supervisor/trunk/CHANGES.txt
==============================================================================
--- supervisor/trunk/CHANGES.txt (original)
+++ supervisor/trunk/CHANGES.txt Sat Oct 24 15:56:37 2009
@@ -39,6 +39,8 @@
- Fixed a bug where the FCGI socket reference count was not getting
decremented on spawn error. (Roger Hoover)
+ - Fixed a Python 2.6 deprecation warning on use of the "sha" module.
+
3.0a7 (2009-05-24)
- We now bundle our own patched version of Medusa contributed by Jason
Modified: supervisor/trunk/src/supervisor/http.py
==============================================================================
--- supervisor/trunk/src/supervisor/http.py (original)
+++ supervisor/trunk/src/supervisor/http.py Sat Oct 24 15:56:37 2009
@@ -21,6 +21,11 @@
import pwd
import urllib
+try:
+ from hashlib import sha1
+except ImportError:
+ from sha import new as sha1
+
from supervisor.medusa import asyncore_25 as asyncore
from supervisor.medusa import http_date
from supervisor.medusa import http_server
@@ -850,8 +855,7 @@
if self.dict.has_key(username):
stored_password = self.dict[username]
if stored_password.startswith('{SHA}'):
- import sha
- password_hash = sha.new(password).hexdigest()
+ password_hash = sha1(password).hexdigest()
return stored_password[5:] == password_hash
else:
return stored_password == password
Modified: supervisor/trunk/src/supervisor/tests/test_http.py
==============================================================================
--- supervisor/trunk/src/supervisor/tests/test_http.py (original)
+++ supervisor/trunk/src/supervisor/tests/test_http.py Sat Oct 24 15:56:37 2009
@@ -4,6 +4,11 @@
import tempfile
import unittest
+try:
+ from hashlib import sha1
+except ImportError:
+ from sha import new as sha1
+
from supervisor.tests.base import DummySupervisor
from supervisor.tests.base import PopulatedDummySupervisor
from supervisor.tests.base import DummyRPCInterfaceFactory
@@ -271,19 +276,11 @@
self.assertEqual(authorizer.authorize(('foo', 'password')), True)
def test_authorize_gooduser_badpassword_sha(self):
- try:
- from hashlib import sha1
- except ImportError:
- from sha import new as sha1
password = '{SHA}' + sha1('password').hexdigest()
authorizer = self._makeOne({'foo':password})
self.assertEqual(authorizer.authorize(('foo', 'bar')), False)
def test_authorize_gooduser_goodpassword_sha(self):
- try:
- from hashlib import sha1
- except ImportError:
- from sha import new as sha1
password = '{SHA}' + sha1('password').hexdigest()
authorizer = self._makeOne({'foo':password})
self.assertEqual(authorizer.authorize(('foo', 'password')), True)
More information about the Supervisor-checkins
mailing list