Fixed unicode query conversion segfault.

This commit is contained in:
Federico Di Gregorio 2005-05-31 01:55:02 +00:00
parent 2804f9a6a9
commit 5322b4e92f
3 changed files with 17 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2005-05-31 Federico Di Gregorio <fog@debian.org>
* psycopg/cursor_type.c (_psyco_curs_execute): if a
UnicodeEncodeError is raised during the converion of a unicode
query we let it propagate insead of segfaulting.
2005-5-27 Federico Di Gregorio, <fog@lana.initd.org>
* tests/types_basic.py: fixed float and binary tests.

6
NEWS
View File

@ -1,3 +1,9 @@
What's new in psycopg 2.0 beta 4
--------------------------------
* No more segfaults when a UNICODE query can't be converted to the
backend encoding.
What's new in psycopg 2.0 beta 3
--------------------------------

View File

@ -245,6 +245,11 @@ _psyco_curs_execute(cursorObject *self,
if (enc) {
operation = PyUnicode_AsEncodedString(
operation, PyString_AsString(enc), NULL);
/* if there was an error during the encoding from unicode to the
target encoding we just let the exception propagate */
if (operation == NULL) return 0;
/* we clone operation in uoperation to be sure to free it later */
uoperation = operation;
}