Export to GitHub

gui2py - issue #1

Non ASCII text input raises UnicodeEncodeError in example form


Posted on Nov 30, 2011 by Helpful Ox

What steps will reproduce the problem? 1. Create a table insert form with the gui2py form example 2. Pass non ascii data to the wx text fields in the html widget

What is the expected output? What do you see instead?

A web2py error is shown in terminal:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 7: ordinal not in range(128)

Please use labels and text to provide additional information.

Not sure, but i think it is only reproduced when using the PostgreSQL db engine.

System Info: Mandriva GNU/Linux, PostgreSQL 8.4, web2py 1.99.2, Python 2.6.5, gui2py hg project clone

Here is the Python error message.

#

Traceback (most recent call last): File "/home/alan/gestionlibre_gui-hg/controllers/appadmin.py", line 191, in create if config.session.form.accepts(evt.args, formname=None, keepvalues=False, dbio=False): File "/home/alan/web2py/gluon/sqlhtml.py", line 1075, in accepts hideerror=hideerror, File "/home/alan/web2py/gluon/html.py", line 1798, in accepts status = self._traverse(status,hideerror) File "/home/alan/web2py/gluon/html.py", line 743, in _traverse newstatus = c._traverse(status,hideerror) and newstatus File "/home/alan/web2py/gluon/html.py", line 743, in _traverse newstatus = c._traverse(status,hideerror) and newstatus File "/home/alan/web2py/gluon/html.py", line 743, in _traverse newstatus = c._traverse(status,hideerror) and newstatus File "/home/alan/web2py/gluon/html.py", line 743, in _traverse newstatus = c._traverse(status,hideerror) and newstatus File "/home/alan/web2py/gluon/html.py", line 750, in _traverse newstatus = self._validate() File "/home/alan/web2py/gluon/html.py", line 1566, in _validate (value, errors) = validator(value) File "/home/alan/web2py/gluon/validators.py", line 530, in call value=str(value) UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 7: ordinal not in range(128)

Comment #1

Posted on Nov 30, 2011 by Helpful Ox

Looking again in the error trace, it seems not to be related to gui2py, but to unicode issues with web2py input. Perhaps this is not a valid gui2py issue.

Comment #2

Posted on Dec 20, 2011 by Helpful Ox

It seems that web2py form validation requires str objects instead of unicode.

Comment #3

Posted on Jan 31, 2012 by Helpful Ox

Now, gui2py encodes unicode input as UTF-8 for web2py compatibility

Status: Fixed

Labels:
Type-Other Priority-Medium