﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
13653	Python 2.4 + hashlib causes AttributeError calling hmac.new()	Karen Tracey	Karen Tracey	"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. "		closed	Core (Other)	1.2		fixed			Accepted	0	0	0	0	0	0
