From 874a74fe9420d76e91a222d37dcf31c20dafc5b0 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Tue, 22 May 2012 17:22:57 +0100 Subject: [PATCH] Dropped GIL release around function calling PyMem_Malloc Closes ticket #110. --- NEWS | 3 +++ psycopg/adapter_qstring.c | 11 +---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 880278be..b7f31bfb 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ What's new in psycopg 2.4.6 - Fixed 'cursor()' arguments propagation in connection subclasses and overriding of the 'cursor_factory' argument. Thanks to Corry Haines for the report and the initial patch (ticket #105). + - Dropped GIL release during string adaptation around a function call + invoking a Python API function, which could cause interpreter crash. + Thanks to Manu Cupcic for the report (ticket #110). What's new in psycopg 2.4.5 diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 773cfa0d..53a87603 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -73,16 +73,7 @@ qstring_quote(qstringObject *self) /* encode the string into buffer */ Bytes_AsStringAndSize(str, &s, &len); - - /* Call qstring_escape with the GIL released, then reacquire the GIL - before verifying that the results can fit into a Python string; raise - an exception if not. */ - - Py_BEGIN_ALLOW_THREADS - buffer = psycopg_escape_string(self->conn, s, len, NULL, &qlen); - Py_END_ALLOW_THREADS - - if (buffer == NULL) { + if (!(buffer = psycopg_escape_string(self->conn, s, len, NULL, &qlen))) { Py_DECREF(str); PyErr_NoMemory(); return NULL;