summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-04-11 19:34:46 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-04-11 19:34:46 -0400
commita0e95869a4a17cc1c162341a05d0c8a04a398f55 (patch)
tree473b07b4ef40558a858dc7176cc73df6d9987eaa
parentee7bb9c1744b4b09263ef32032afd38f694df136 (diff)
downloadsqlalchemy-a0e95869a4a17cc1c162341a05d0c8a04a398f55.tar.gz
The _Binary base type now converts values through
the bytes() callable when run on Python 3; in particular psycopg2 2.5 with Python 3.3 seems to now be returning the "memoryview" type, so this is converted to bytes before return.
-rw-r--r--doc/build/changelog/changelog_08.rst9
-rw-r--r--lib/sqlalchemy/types.py11
2 files changed, 18 insertions, 2 deletions
diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst
index 50d31a094..8df055e10 100644
--- a/doc/build/changelog/changelog_08.rst
+++ b/doc/build/changelog/changelog_08.rst
@@ -7,6 +7,15 @@
:version: 0.8.1
.. change::
+ :tags: bug, sql, postgresql
+
+ The _Binary base type now converts values through
+ the bytes() callable when run on Python 3; in particular
+ psycopg2 2.5 with Python 3.3 seems to now be returning
+ the "memoryview" type, so this is converted to bytes
+ before return.
+
+ .. change::
:tags: bug, sql
:tickets: 2695
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py
index 08aba4b56..1824a9b3f 100644
--- a/lib/sqlalchemy/types.py
+++ b/lib/sqlalchemy/types.py
@@ -1711,8 +1711,15 @@ class _Binary(TypeEngine):
return process
# Python 3 has native bytes() type
- # both sqlite3 and pg8000 seem to return it
- # (i.e. and not 'memoryview')
+ # both sqlite3 and pg8000 seem to return it,
+ # psycopg2 as of 2.5 returns 'memoryview'
+ # Py3K
+ #def result_processor(self, dialect, coltype):
+ # def process(value):
+ # if value is not None:
+ # value = bytes(value)
+ # return value
+ # return process
# Py2K
def result_processor(self, dialect, coltype):
if util.jython: