From 78eb80d0cfb305d7eb467f7f25fdea50d379dd0b Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Mon, 17 Jul 2017 10:54:50 +0530 Subject: [PATCH] Using 'Text_FromUTF8' macro for transforming the encrypted C string to Python string to make it Python 3 compatible. --- psycopg/connection_type.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 7d365f3f..52c1a9f8 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -575,8 +575,8 @@ psyco_encrypt_password(connectionObject *self, PyObject *args, PyObject *kwargs) if (encrypted != NULL) { - res = PyString_FromString(encrypted); - free(encrypted); + res = Text_FromUTF8(encrypted); + PQfreemem(encrypted); } return res; } @@ -600,10 +600,11 @@ psyco_encrypt_password(connectionObject *self, PyObject *args, PyObject *kwargs) } else { - res = PyString_FromString(encrypted); + res = Text_FromUTF8(encrypted); + PQfreemem(encrypted); } - return res; + #else PyErr_SetString( NotSupportedError,