Skip to content

Commit 620ad41

Browse files
authored
Merge pull request #4127 from arnaud-morvan/processing_fix_postgis_dberror
[processing] Fix infinite recursion in DbError.__str__
2 parents 3496871 + 5028cc7 commit 620ad41

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

python/plugins/processing/tools/postgis.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,9 @@ def __init__(self, message, query=None):
136136
self.query = query
137137

138138
def __str__(self):
139-
return str(self).encode('utf-8')
140-
141-
def __unicode__(self):
142-
text = u'MESSAGE: %s' % self.message
139+
text = "MESSAGE: {}".format(self.message)
143140
if self.query:
144-
text += u'\nQUERY: %s' % self.query
141+
text = "{}\nQUERY: {}".format(text, self.query)
145142
return text
146143

147144

@@ -829,7 +826,8 @@ def _exec_sql(self, cursor, sql):
829826
try:
830827
cursor.execute(sql)
831828
except psycopg2.Error as e:
832-
raise DbError(str(e), e.cursor.query)
829+
raise DbError(str(e),
830+
e.cursor.query.decode(e.cursor.connection.encoding))
833831

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

0 commit comments

Comments
 (0)