From 5322b4e92f8b05a3bdd3e7b87d59322b35de788d Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Tue, 31 May 2005 01:55:02 +0000 Subject: [PATCH] Fixed unicode query conversion segfault. --- ChangeLog | 6 ++++++ NEWS | 6 ++++++ psycopg/cursor_type.c | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2002420a..0d775798 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-05-31 Federico Di Gregorio + + * 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, * tests/types_basic.py: fixed float and binary tests. diff --git a/NEWS b/NEWS index 84e9bad2..689967a5 100644 --- a/NEWS +++ b/NEWS @@ -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 -------------------------------- diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index 4b3de5b0..b2a05d70 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -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; }