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/tom/canonical/lp-branches/bug-129948/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?).
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/ tom/canonical/ lp-branches/bug-129948/lib/zope/ testbrowser/ browser. py", line 568, in click
self.browser. _clickSubmit( self.mech_ form, self.mech_control, (1,1)) user/project/ lib/zope/ testbrowser/ browser. py", line 357, in _clickSubmit
self.mech_ browser. open(form. click( python2. 4/site- packages/ ClientForm. py", line 2935, in click
self._ request_ class) python2. 4/site- packages/ ClientForm. py", line 3141, in _click _click( self, coord, return_type, request_class) python2. 4/site- packages/ ClientForm. py", line 2299, in _click click(return_ type, request_class) python2. 4/site- packages/ ClientForm. py", line 3209, in _switch_click data() python2. 4/site- packages/ ClientForm. py", line 3192, in _request_data
self.controls[ control_ index]. _write_ mime_data( mw, k, v) python2. 4/site- packages/ ClientForm. py", line 1136, in _write_mime_data
f.write( value) deError: 'ascii' codec can't encode character u'\xab' in position 0: ordinal not in range(128)
File "/home/
File "/usr/lib/
File "/usr/lib/
return control.
File "/usr/lib/
r = form._switch_
File "/usr/lib/
req_data = self._request_
File "/usr/lib/
File "/usr/lib/
UnicodeEnco
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?).