From: Mike Bayer Date: Thu, 11 Apr 2013 23:34:46 +0000 (-0400) Subject: The _Binary base type now converts values through X-Git-Tag: rel_0_8_1~16^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0e95869a4a17cc1c162341a05d0c8a04a398f55;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git 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. --- 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: