From a0e95869a4a17cc1c162341a05d0c8a04a398f55 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 11 Apr 2013 19:34:46 -0400 Subject: [PATCH] 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. --- doc/build/changelog/changelog_08.rst | 9 +++++++++ lib/sqlalchemy/types.py | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index 50d31a094f..8df055e10f 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,15 @@ .. changelog:: :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 08aba4b56b..1824a9b3fd 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: -- 2.47.3