#13653: Python 2.4 + hashlib causes AttributeError calling hmac.new()
----------------------------+-----------------------------------------------
Reporter: kmtracey | Owner: nobody
Status: new | Milestone:
Component: Core framework | Version: 1.2
Keywords: | Stage: Unreviewed
Has_patch: 0 |
----------------------------+-----------------------------------------------
If you install the [http://pypi.python.org/pypi/hashlib/20081119
standalone hashlib module] on Python 2.4, attempting to do anything the
admin that requires creation of a message results in an error:
{{{
Traceback (most recent call last):
File "C:\u\kmt\django\trunk\django\core\servers\basehttp.py", line 280,
in run
self.result = application(self.environ, self.start_response)
File "C:\u\kmt\django\trunk\django\core\servers\basehttp.py", line 674,
in __call__
return self.application(environ, start_response)
File "C:\u\kmt\django\trunk\django\core\handlers\wsgi.py", line 245, in
__call__
response = middleware_method(request, response)
File "C:\u\kmt\django\trunk\django\contrib\messages\middleware.py", line
23, in process_response
unstored_messages = request._messages.update(response)
File "C:\u\kmt\django\trunk\django\contrib\messages\storage\base.py",
line 138, in update
return self._store(messages, response)
File
"C:\u\kmt\django\trunk\django\contrib\messages\storage\fallback.py", line
48, in _store
remove_oldest=False)
File "C:\u\kmt\django\trunk\django\contrib\messages\storage\cookie.py",
line 91, in _store
encoded_data = self._encode(messages)
File "C:\u\kmt\django\trunk\django\contrib\messages\storage\cookie.py",
line 128, in _encode
return '%s$%s' % (self._hash(value), value)
File "C:\u\kmt\django\trunk\django\contrib\messages\storage\cookie.py",
line 115, in _hash
return hmac.new(key, value, sha_hmac).hexdigest()
File "C:\bin\Python24\lib\hmac.py", line 107, in new
return HMAC(key, msg, digestmod)
File "C:\bin\Python24\lib\hmac.py", line 42, in __init__
self.outer = digestmod.new()
AttributeError: 'builtin_function_or_method' object has no attribute 'new'
}}}
The `django.utils.hashcompat` module assumes that if hashlib imports
without error, then the whole stdlib is 2.5. But when running on
2.4+standalone hashlib, we've got 2.4 hmac, and the sha_hmac value set in
hashcompat needs to be the one for 2.4, not the value that works for 2.5+
and is set when the hashlib import succeeds.
--
Ticket URL: <http://code.djangoproject.com/ticket/13653>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.