chtd / psycopg2cffi

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

Notice handler fails when notice contains utf8 bytes #72

Closed asterite3 closed 7 years ago

asterite3 commented 7 years ago

Notice can arive from server as utf8 and it's decoding as ascii can cause and error, for example:

From cffi callback <function <lambda> at 0x0000000001dbab60>:
Traceback (most recent call last):
  File "psycopg2cffi/_impl/connection.py", line 132, in <lambda>
    arg, bytes_to_ascii(ffi.string(message))))
  File "psycopg2cffi/_impl/adapters.py", line 314, in bytes_to_ascii
    return b.decode('ascii')
UnicodeDecodeError: ('ascii', '...

Same issue as https://github.com/chtd/psycopg2cffi/issues/56

lopuhin commented 7 years ago

Thanks @asterite3 👍