summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKevin Campbell <kev@projectcolo.org.uk>2017-11-03 17:30:06 +0800
committerKevin Campbell <kev@projectcolo.org.uk>2017-11-03 17:30:06 +0800
commitb804c092ac2897cb139810c025ff4f998c7c66d4 (patch)
tree3a7f2dcc414184f58987d6ad8e13299c63cc9792 /lib
parentdfee199351429a4170c7d190fbecacb35777de2e (diff)
downloadpsycopg2-b804c092ac2897cb139810c025ff4f998c7c66d4.tar.gz
Patch for issue #609 for MinTimeLoggingConnection
On Python3 MinTimeLoggingConnection raises an exception as it tries to mix strings and bytes
Diffstat (limited to 'lib')
-rw-r--r--lib/extras.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/extras.py b/lib/extras.py
index 798b3d2..7ee52c7 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -455,6 +455,8 @@ class MinTimeLoggingConnection(LoggingConnection):
def filter(self, msg, curs):
t = (_time.time() - curs.timestamp) * 1000
if t > self._mintime:
+ if _sys.version_info[0] >= 3 and isinstance(msg, bytes):
+ msg = msg.decode(_ext.encodings[self.encoding], 'replace')
return msg + _os.linesep + " (execution time: %d ms)" % t
def cursor(self, *args, **kwargs):