From 4ba0e1a6f307d434356c24fb5c577b1d16826371 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Thu, 21 Jun 2018 17:06:28 -0400 Subject: [PATCH] Fix Python 2.6 support for SQL_ASCII data in the query tool. --- web/pgadmin/utils/driver/psycopg2/connection.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/web/pgadmin/utils/driver/psycopg2/connection.py b/web/pgadmin/utils/driver/psycopg2/connection.py index e8ed88a30..1b4d2a3f2 100644 --- a/web/pgadmin/utils/driver/psycopg2/connection.py +++ b/web/pgadmin/utils/driver/psycopg2/connection.py @@ -622,14 +622,15 @@ WHERE # We need to esacpe the data so that it does not fail when # it is encoded with python ascii # unicode_escape helps in escaping and unescaping - if self.conn.encoding in ('SQL_ASCII', 'SQLASCII', - 'MULE_INTERNAL', 'MULEINTERNAL')\ - and params is not None and type(params) == dict: - params = { - key: val.encode('unicode_escape') - .decode('raw_unicode_escape') - for key, val in params.items() - } + if self.conn: + if self.conn.encoding in ('SQL_ASCII', 'SQLASCII', + 'MULE_INTERNAL', 'MULEINTERNAL')\ + and params is not None and type(params) == dict: + params = dict( + (key, val.encode('unicode_escape') + .decode('raw_unicode_escape')) + for key, val in params.items() + ) return params def __internal_blocking_execute(self, cur, query, params):