diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2016-12-29 22:36:04 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2016-12-29 22:42:25 +0100 |
commit | 21f38a4c074d106c24e48e8e971d7215dace5911 (patch) | |
tree | 107418cafd23e2752b028cb5461e62c7cddc9fec /lib/extras.py | |
parent | 449bd4485f10bcf4dd557c62912623ec2774d86b (diff) | |
download | psycopg2-21f38a4c074d106c24e48e8e971d7215dace5911.tar.gz |
Don't try to write bytes in the LoggingConnection file
Close #483
Diffstat (limited to 'lib/extras.py')
-rw-r--r-- | lib/extras.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/extras.py b/lib/extras.py index 7fc853a..b59a2c7 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): |