Grok python 2.6 HMAC

Bug #324327 reported by yvan
4
Affects Status Importance Assigned to Milestone
grok
Fix Released
Undecided
Kevin Teague

Bug Description

try to run grok with python2.6, I have edited the buildout.cfg like that:
[versions]
mechanize = 0.1.9
zope.app.appsetup = 3.8.0
zope.app.component = 3.5.0
zope.app.container = 3.6.1
zope.app.form = 3.6.3
zope.app.publisher = 3.5.1
zope.app.testing = 3.5.6
zope.testbrowser = 3.5.1

According to the mailing list email from <email address hidden> subject [Grok-dev] Grok runs on Python 2.6 published the 15th Oct. 2008. But I am unable to get to to this URL http://localhost:8080/applications. But if i try to go directly to
http://localhost:8080/application_name/ it is ok.
This could be related to this mail
http://www.nabble.com/TypeError-when-adding-an-app-from-the-tutorial-td21707217.html
but I don't know if a bug report was already filled ( at least I was not able to find it)

Is it the best place to report this problem?
Cheers,
yvan

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.

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

Ignore my previous comment about the translate() method, the problem is that there was an optimization made to the hmac module in Python 2.6 that had the seemlingly unintended effect that unicode strings are no longer accepted as input. I've filled a bug in the Python issue tracker (http://bugs.python.org/issue5285) but this "str() as input only" bug will still need handling in zope.session to work with Python 2.6.

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

zope.session 3.8.1 has been released, so adding it in the versions should fix this issue.

[versions]
zope.session = 3.8.1

Changed in grok:
assignee: nobody → kevin-bud
status: New → Fix Released
Revision history for this message
yvan (yvan-strahm) wrote :

Thank you very much, it works nicely
cheers,

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.