Comment 18 for bug 899794

Revision history for this message
tamnil (saito-x) wrote : Re: [6.1] random requests fail with "TypeError: can't escape non-string object"

as described in bug: Bug #919982 by ruy medeiros

"
Hi,

I'm using Ubuntu 10.04 with Postgresql 8.4.10, psycopg 2.4.4, Openerp 6.1 RC1 and got struck with this error too. All forms with binary fields in the model were causing this error.

After fiddling in google, I found this bug report http://psycopg.lighthouseapp.com/projects/62710/tickets/51-typeerror-cant-escape-unicode-to-binary-writing-unicode-into-bytea which made me suspicious that openerp was trying to convert to binary the form field as unicode, thus psycopg threw the error.

I have no idea if this is the right fix, but what I did to sort it out was to cast the form field content as a string before the binary conversion by psycopg in osv/fields.py the end result is:

_symbol_f = lambda symb: symb and Binary(str(symb)) or None

on line 296 of osv/fields.py

Again, I have no idea whatsoever if this is the right fix, I'm sure this is where the problem is caused though.

Best regards,"

it was worked fine.!
but in my version it´s in line 332.
i don´t know how it affect the other fields.