chtd / psycopg2cffi

Port to cffi with some speed improvements
Other
177 stars 43 forks source link

Can't decode ascii exception messages #75

Open raimonesteve opened 7 years ago

raimonesteve commented 7 years ago

Hie,

working with psycopg2cffi backend, in exception database (SQL constrains) can't encode ASCII character.

Is it possible exceptions database to encoding with unicode?

More information: https://bugs.tryton.org/issue6128

The traceback:

Traceback (most recent call last): File "/home/xxx/tryton/trytond/trytond/protocols/dispatcher.py", line 160, in _dispatch result = rpc.result(meth(*c_args, **c_kwargs)) File "/home/xxx/tryton/trytond/trytond/modules/account_parent_code/account.py", line 98, in create accounts = super(Account, cls).create(vlist) File "/home/xxx/tryton/trytond/trytond/model/modelsql.py", line 558, in create exception, values, transaction=transaction) File "/home/xxx/tryton/trytond/trytond/model/modelsql.py", line 307, in __raise_integrity_error if name in str(exception): UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 31: ordinal not in range(128)

lopuhin commented 7 years ago

Hi, thanks for the bug report! str(exception) definitely should not fail, I'll try to figure out why that happens.

vperilla commented 7 years ago

Try with this:

def str(self): return unicode(self.message).encode('utf-8')

inside Error class