Test browser can't handle non-ascii characters in form data

Bug #130857 reported by Eleanor Berger
This bug report is a duplicate of:  Bug #71960: Support unicode string in testbrowser. Edit Remove
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zope 3
Won't Fix
Undecided
Unassigned
zope.testbrowser
New
Undecided
Unassigned

Bug Description

In a test, I assign a unicode string with some non-ascii characters to the value of a field, and submit the form. I then get the following error (fragment):

      File "/home/user/project/lib/zope/testbrowser/browser.py", line 568, in click
        self.browser._clickSubmit(self.mech_form, self.mech_control, (1,1))
      File "/home/user/project/lib/zope/testbrowser/browser.py", line 357, in _clickSubmit
        self.mech_browser.open(form.click(
      File "/usr/lib/python2.4/site-packages/ClientForm.py", line 2935, in click
        self._request_class)
      File "/usr/lib/python2.4/site-packages/ClientForm.py", line 3141, in _click
        return control._click(self, coord, return_type, request_class)
      File "/usr/lib/python2.4/site-packages/ClientForm.py", line 2299, in _click
        r = form._switch_click(return_type, request_class)
      File "/usr/lib/python2.4/site-packages/ClientForm.py", line 3209, in _switch_click
        req_data = self._request_data()
      File "/usr/lib/python2.4/site-packages/ClientForm.py", line 3192, in _request_data
        self.controls[control_index]._write_mime_data(mw, k, v)
      File "/usr/lib/python2.4/site-packages/ClientForm.py", line 1136, in _write_mime_data
        f.write(value)
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xab' in position 0: ordinal not in range(128)

To behave more like a real browser, the test browser should automatically encode its content, trying to get the desired encoding from the form, or if that fails, from the page or from a sensible default (utf-8?).

description: updated
Tres Seaver (tseaver)
Changed in zope3:
status: New → Won't Fix
Revision history for this message
Tres Seaver (tseaver) wrote :

Mis-assigned.

affects: zope.testing → zope.testbrowser
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.