From: Mike Bayer Date: Tue, 26 May 2009 17:21:41 +0000 (+0000) Subject: most ORM tests passing in py3.1 with these changes X-Git-Tag: rel_0_6_6~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1cbda5c003221279efe8085f774575639b4ea0d1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git most ORM tests passing in py3.1 with these changes --- diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 9d0f2cb4cd..6f45c4ef53 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1601,8 +1601,11 @@ class ResultProxy(object): for i, item in enumerate(metadata): colname = item[0] + # Py3K + # Py2K if self.dialect.description_encoding: colname = colname.decode(self.dialect.description_encoding) + # end Py2K if '.' in colname: # sqlite will in some circumstances prepend table name to colnames, so strip diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index be40b08c65..882e25f31b 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -579,7 +579,11 @@ class Query(object): def value(self, column): """Return a scalar result corresponding to the given column expression.""" try: + # Py3K + #return self.values(column).__next__()[0] + # Py2K return self.values(column).next()[0] + # end Py2K except StopIteration: return None diff --git a/test/testlib/compat.py b/test/testlib/compat.py index 674a2d50fb..c6af2ba274 100644 --- a/test/testlib/compat.py +++ b/test/testlib/compat.py @@ -5,7 +5,7 @@ import types import __builtin__ -__all__ = '_function_named', 'callable', 'py3k', 'jython', 'to_list' +__all__ = '_function_named', 'callable', 'py3k', 'jython', 'to_list', 'cmp' py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0) @@ -36,9 +36,13 @@ def to_list(x, default=None): if py3k: def callable(fn): return hasattr(fn, '__call__') + def cmp(a, b): + return (a > b) - (a < b) + else: callable = __builtin__.callable - + cmp = __builtin__.cmp + if sys.platform.startswith('java'): def gc_collect(*args): gc.collect() diff --git a/test/testlib/sa_unittest.py b/test/testlib/sa_unittest.py index 7d7ea119e9..67a46a4694 100644 --- a/test/testlib/sa_unittest.py +++ b/test/testlib/sa_unittest.py @@ -41,7 +41,7 @@ import sys import traceback import os import types -from testlib.compat import callable +from testlib.compat import callable, cmp ############################################################################## # Exported classes and functions