From: Jason Kirtland Date: Mon, 10 Nov 2008 22:56:22 +0000 (+0000) Subject: Quashed import sets deprecation warning on 2.6.. not wild about this but it seems... X-Git-Tag: rel_0_5rc4~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d403d8b865884b05169c7d56d0545e84088ba8a4;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Quashed import sets deprecation warning on 2.6.. not wild about this but it seems like it will be ok. [ticket:1209] --- diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index f2f2cdd79c..297dd738f1 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -4,7 +4,7 @@ # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php -import inspect, itertools, new, operator, sets, sys, warnings, weakref +import inspect, itertools, new, operator, sys, warnings, weakref import __builtin__ types = __import__('types') @@ -18,8 +18,20 @@ except ImportError: import dummy_threading as threading from dummy_threading import local as ThreadLocal -# TODO: 2.6 will whine about importing `sets`, but I think we still need it to -# around to support older DB-API modules that return the 2.3 style set. +if sys.version_info < (2, 6): + import sets +else: + # 2.6 deprecates sets.Set, but we still need to be able to detect them + # in user code and as return values from DB-APIs + ignore = ('ignore', None, DeprecationWarning, None, 0) + try: + warnings.filters.insert(0, ignore) + except Exception: + import sets + else: + import sets + warnings.filters.remove(ignore) + set_types = set, sets.Set EMPTY_SET = frozenset() diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py index caafb39f64..45f9d289ac 100644 --- a/test/dialect/postgres.py +++ b/test/dialect/postgres.py @@ -96,9 +96,11 @@ class ReturningTest(TestBase, AssertsExecutionResults): self.assertEqual(result.fetchall(), [(1,)]) # Multiple inserts only return the last row + testing.db.echo = True result2 = table.insert(postgres_returning=[table]).execute( [{'persons': 2, 'full': False}, {'persons': 3, 'full': True}]) - + from pdb import set_trace; set_trace() + print vars(result2) self.assertEqual(result2.fetchall(), [(3,3,True)]) result3 = table.insert(postgres_returning=[(table.c.id*2).label('double_id')]).execute({'persons': 4, 'full': False})