summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2005-05-31 01:55:02 +0000
committerFederico Di Gregorio <fog@initd.org>2005-05-31 01:55:02 +0000
commit5322b4e92f8b05a3bdd3e7b87d59322b35de788d (patch)
tree6456aa16e95046a4c58c9d8a9c1596009653bc74
parent2804f9a6a98fb0f135165ef726b1d3f7c827f31c (diff)
downloadpsycopg2-5322b4e92f8b05a3bdd3e7b87d59322b35de788d.tar.gz
Fixed unicode query conversion segfault.
-rw-r--r--ChangeLog6
-rw-r--r--NEWS6
-rw-r--r--psycopg/cursor_type.c5
3 files changed, 17 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2002420..0d77579 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/NEWS b/NEWS
index 84e9bad..689967a 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 4b3de5b..b2a05d7 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;
}