zope.formlib.form.Action does not work with Unicode label

Bug #528466 reported by yasusii
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
BlueBream
New
Undecided
Unassigned
zope.formlib
Fix Released
Low
Charlie_X

Bug Description

>>> from zope.formlib.form import Action
>>> Action(u'\u9001\u4fe1')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/yasusii/.buildout/eggs/zope.formlib-4.0-py2.5.egg/zope/formlib/form.py", line 575, in __init__
    name = label.encode('hex')
  File "/usr/lib/python2.5/encodings/hex_codec.py", line 24, in hex_encode
    output = binascii.b2a_hex(input)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

Revision history for this message
yasusii (yasusii) wrote :
Tres Seaver (tseaver)
affects: zopetoolkit-project → zope.formlib
Tres Seaver (tseaver)
tags: added: bugday20100424
Revision history for this message
Tres Seaver (tseaver) wrote :

As a workaround for this bug, you can pass the 'name' for the action in addition to the label. E.g.:

  Action(u'\u9001\u4fe1', name='my_action')

Thanks for the report!

Changed in zope.formlib:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Charlie_X (charlie) wrote :

The patch solves the wrong problem - labels can be unicode, indeed ASCII is coerced to unicode. hex is used for whitespace. The regex needs updating to cope with unicode. And a test is required.

Revision history for this message
Charlie_X (charlie) wrote :

Fix applied in #111406

Changed in zope.formlib:
assignee: nobody → Charlie_X (charlie)
status: Triaged → Fix Committed
Revision history for this message
Tres Seaver (tseaver) wrote :

Fix released with zope.formlib 4.0.3:

 http://pypi.python.org/pypi/zope.formlib/4.0.3

Changed in zope.formlib:
status: Fix Committed → Fix Released
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.