From b804c092ac2897cb139810c025ff4f998c7c66d4 Mon Sep 17 00:00:00 2001 From: Kevin Campbell Date: Fri, 3 Nov 2017 17:30:06 +0800 Subject: [PATCH 1/2] Patch for issue #609 for MinTimeLoggingConnection On Python3 MinTimeLoggingConnection raises an exception as it tries to mix strings and bytes --- lib/extras.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/extras.py b/lib/extras.py index 798b3d2b..7ee52c75 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): From b4f066bd43545a96ec98c94a4460d2b5372379a7 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Tue, 28 Nov 2017 03:22:53 +0000 Subject: [PATCH 2/2] Mention MinTimeLoggingCursor fix in NEWS file --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index 799477ec..0c3ebe5f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ Current release --------------- +What's new in psycopg 2.7.4 +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Fixed `MinTimeLoggingCursor` on Python 3 (:ticket:`#609`). + + What's new in psycopg 2.7.3.2 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^