Don't try to write bytes in the LoggingConnection file

Close #483
This commit is contained in:
Daniele Varrazzo 2016-12-29 22:36:04 +01:00
parent 449bd4485f
commit 21f38a4c07
2 changed files with 4 additions and 0 deletions

2
NEWS
View File

@ -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:

View File

@ -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):