Skip to content

Commit

Permalink
[processing] Fix infinite recursion in DbError.__str__
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-morvan committed Feb 13, 2017
1 parent 2c188b2 commit 5028cc7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions python/plugins/processing/tools/postgis.py
Expand Up @@ -136,12 +136,9 @@ def __init__(self, message, query=None):
self.query = query

def __str__(self):
return str(self).encode('utf-8')

def __unicode__(self):
text = u'MESSAGE: %s' % self.message
text = "MESSAGE: {}".format(self.message)
if self.query:
text += u'\nQUERY: %s' % self.query
text = "{}\nQUERY: {}".format(text, self.query)
return text


Expand Down Expand Up @@ -829,7 +826,8 @@ def _exec_sql(self, cursor, sql):
try:
cursor.execute(sql)
except psycopg2.Error as e:
raise DbError(str(e), e.cursor.query)
raise DbError(str(e),
e.cursor.query.decode(e.cursor.connection.encoding))

def _exec_sql_and_commit(self, sql):
"""Tries to execute and commit some action, on error it rolls
Expand Down

0 comments on commit 5028cc7

Please sign in to comment.