diff --git a/NEWS b/NEWS index ecde78d3..b4d11e64 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,8 @@ New features: - `~cursor.callproc()` now accepts a dictionary of parameters (:ticket:`#381`). - Using Python C API decoding functions and codecs caching for faster unicode encoding/decoding (:ticket:`#473`). +- Fixed error caused by missing decoding `~psycopg2.extras.LoggingConnection` + (:ticket:`#483`). Other changes: diff --git a/lib/extras.py b/lib/extras.py index 7fc853a6..b59a2c76 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -395,6 +395,8 @@ class LoggingConnection(_connection): def _logtofile(self, msg, curs): msg = self.filter(msg, curs) if msg: + if _sys.version_info[0] >= 3 and isinstance(msg, bytes): + msg = msg.decode(_ext.encodings[self.encoding], 'replace') self._logobj.write(msg + _os.linesep) def _logtologger(self, msg, curs):