New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinTimeLoggingCursor errors in python3 #609

kevcampb opened this Issue Nov 3, 2017 · 0 comments


None yet
2 participants

kevcampb commented Nov 3, 2017

When using a connection_factory of psycopg2.extras.MinTimeLoggingCursor in python3, a traceback is raised due to mixing str and bytes.

The same issue was patched in #483 in commit 21f38a4 for LoggingConnection, but the same patch did not get applied to the subclass.

Error should look like the following

Traceback (most recent call last):
  File ""
  File "miniconda3/envs/batch-data-pipeline-env/lib/python3.6/site-packages/psycopg2/", line 470, in execute
    return LoggingCursor.execute(self, query, vars)
  File "miniconda3/envs/batch-data-pipeline-env/lib/python3.6/site-packages/psycopg2/", line 431, in execute
    self.connection.log(self.query, self)
  File "miniconda3/envs/batch-data-pipeline-env/lib/python3.6/site-packages/psycopg2/", line 402, in _logtofile
    msg = self.filter(msg, curs)
  File "miniconda3/envs/batch-data-pipeline-env/lib/python3.6/site-packages/psycopg2/", line 458, in filter
    return msg + _os.linesep + "  (execution time: %d ms)" % t
TypeError: can't concat str to bytes

kevcampb added a commit to kevcampb/psycopg2 that referenced this issue Nov 3, 2017

Patch for issue psycopg#609 for MinTimeLoggingConnection
On Python3 MinTimeLoggingConnection raises an exception as it tries to
mix strings and bytes

@dvarrazzo dvarrazzo added this to the psycopg 2.7.4 milestone Nov 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment