Comment 1 for bug 324327

Revision history for this message
Kevin Teague (kevin-bud) wrote :

I believe this is because the translate() string method changed in Python 2.6 (http://bugs.python.org/issue1071) so that it now throws an error when trying to translate a unicode string with a str translation table.

On Python 2.4 and 2.5 you can do:

>>> import hmac
>>> import sha
>>> hmac.new(u'nmeVoOHGCGpx4XMhmTbl3jGG4vg','0.93817239745203817591',sha)
<hmac.HMAC instance at 0x6bf08>

But on Python 2.6 this throws a "TypeError: character mapping must return integer, None or unicode".

A possible fix is to str() the session key before calling hmac.new() in zope.session. This works, but I'm not sure if this solution introduces any other bugs or if there is a better place to workaround this bug.