]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
*most* py3k warnings are resolved, with the exception of the various __setslice__...
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 18 Dec 2008 18:46:27 +0000 (18:46 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 18 Dec 2008 18:46:27 +0000 (18:46 +0000)
I don't really know how to get rid of

lib/sqlalchemy/databases/mssql.py
lib/sqlalchemy/orm/collections.py
lib/sqlalchemy/sql/expression.py
test/orm/inheritance/polymorph.py
test/orm/inheritance/query.py
test/orm/mapper.py
test/testlib/assertsql.py
test/testlib/sa_unittest.py

index 5fb4361b99fd59dfafae976d7960c6703b1e9feb..84f95fad99605b0872c3141adf27d7420fcbe9a3 100644 (file)
@@ -1044,7 +1044,7 @@ class MSSQLCompiler(compiler.DefaultCompiler):
             and not isinstance(binary.right, expression._BindParamClause):
             return self.process(expression._BinaryExpression(binary.right, binary.left, binary.operator), **kwargs)
         else:
-            if (binary.operator in (operator.eq, operator.ne)) and (
+            if (binary.operator is operator.eq or binary.operator is operator.ne) and (
                 (isinstance(binary.left, expression._FromGrouping) and isinstance(binary.left.element, expression._ScalarSelect)) or \
                 (isinstance(binary.right, expression._FromGrouping) and isinstance(binary.right.element, expression._ScalarSelect)) or \
                  isinstance(binary.left, expression._ScalarSelect) or isinstance(binary.right, expression._ScalarSelect)):
index 3c1c16b7df515c11a253eb3861326df4410682fd..5638a7e4a517ea3214856055f1eeed715d27a34c 100644 (file)
@@ -99,7 +99,6 @@ through the adapter, allowing for some very sophisticated behavior.
 import copy
 import inspect
 import operator
-import sets
 import sys
 import weakref
 
@@ -1128,7 +1127,11 @@ def _dict_decorators():
     l.pop('Unspecified')
     return l
 
-_set_binop_bases = (set, frozenset, sets.BaseSet)
+if util.py3k:
+    _set_binop_bases = (set, frozenset)
+else:
+    import sets
+    _set_binop_bases = (set, frozenset, sets.BaseSet)
 
 def _set_binops_check_strict(self, obj):
     """Allow only set, frozenset and self.__class__-derived objects in binops."""
index a4ff72b1af9db5eda23aff6921ce1f20bbafb77b..b7d4965dd5e7f7694661c19d3f511731a210ac8f 100644 (file)
@@ -2128,7 +2128,7 @@ class ClauseList(ClauseElement):
         return list(itertools.chain(*[c._from_objects for c in self.clauses]))
 
     def self_group(self, against=None):
-        if self.group and self.operator != against and operators.is_precedent(self.operator, against):
+        if self.group and self.operator is not against and operators.is_precedent(self.operator, against):
             return _Grouping(self)
         else:
             return self
index cbdbd4c008cccde217e298adf075f9a3f317fd53..aa241cea85cf374ba0d509a67663f28d6fbf3dd7 100644 (file)
@@ -1,7 +1,6 @@
 """tests basic polymorphic mapper loading/saving, minimal relations"""
 
 import testenv; testenv.configure_for_tests()
-import sets
 from sqlalchemy import *
 from sqlalchemy.orm import *
 from sqlalchemy.orm import exc as orm_exc
index 601d5be6ca3e05aadcf4d71d38c3314433fb8063..f362ea0974b7a6bae39e1e486de1f8fb5ea08905 100644 (file)
@@ -4,7 +4,6 @@ and inheriting mappers."""
 # TODO: under construction !
 
 import testenv; testenv.configure_for_tests()
-import sets
 from sqlalchemy import *
 from sqlalchemy.orm import *
 from sqlalchemy import exc as sa_exc
index 6fa532043d9a922255f49d0aae0a56888f77663e..e30b534281bfddbd95af23d4cf5508c7a4c7fdab 100644 (file)
@@ -222,6 +222,8 @@ class MapperTest(_fixtures.FixtureTest):
         mapper(Address, addresses)
 
         class UCComparator(sa.orm.PropComparator):
+            __hash__ = None
+            
             def __eq__(self, other):
                 cls = self.prop.parent.class_
                 col = getattr(cls, 'name')
@@ -696,6 +698,7 @@ class MapperTest(_fixtures.FixtureTest):
                 return 'value'
 
         class UCComparator(sa.orm.PropComparator):
+            __hash__ = None
             def __eq__(self, other):
                 cls = self.prop.parent.class_
                 col = getattr(cls, 'name')
@@ -1158,6 +1161,7 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL):
         from sqlalchemy.orm.properties import ColumnProperty
         
         class MyFactory(ColumnProperty.Comparator):
+            __hash__ = None
             def __eq__(self, other):
                 return func.foobar(self.__clause_element__()) == func.foobar(other)
         mapper(User, users, properties={'name':column_property(users.c.name, comparator_factory=MyFactory)})
@@ -1168,6 +1172,7 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL):
     def test_synonym(self):
         from sqlalchemy.orm.properties import ColumnProperty
         class MyFactory(ColumnProperty.Comparator):
+            __hash__ = None
             def __eq__(self, other):
                 return func.foobar(self.__clause_element__()) == func.foobar(other)
         mapper(User, users, properties={'name':synonym('_name', map_column=True, comparator_factory=MyFactory)})
@@ -1179,10 +1184,12 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL):
         from sqlalchemy.orm.properties import PropertyLoader
 
         class MyFactory(PropertyLoader.Comparator):
+            __hash__ = None
             def __eq__(self, other):
                 return func.foobar(self.__clause_element__().c.user_id) == func.foobar(other.id)
 
         class MyFactory2(PropertyLoader.Comparator):
+            __hash__ = None
             def __eq__(self, other):
                 return func.foobar(self.__clause_element__().c.id) == func.foobar(other.user_id)
                 
@@ -1610,6 +1617,7 @@ class CompositeTypesTest(_base.MappedTest):
                 self.y = y
             def __composite_values__(self):
                 return [self.x, self.y]
+            __hash__ = None
             def __eq__(self, other):
                 return other.x == self.x and other.y == self.y
             def __ne__(self, other):
@@ -1689,6 +1697,7 @@ class CompositeTypesTest(_base.MappedTest):
                 self.version = version
             def __composite_values__(self):
                 return (self.id, self.version)
+            __hash__ = None
             def __eq__(self, other):
                 return other.id == self.id and other.version == self.version
             def __ne__(self, other):
@@ -1748,6 +1757,7 @@ class CompositeTypesTest(_base.MappedTest):
                 self.x4 = x4
             def __composite_values__(self):
                 return self.x1, self.x2, self.x3, self.x4
+            __hash__ = None
             def __eq__(self, other):
                 return other.x1 == self.x1 and other.x2 == self.x2 and other.x3 == self.x3 and other.x4 == self.x4
             def __ne__(self, other):
@@ -1783,6 +1793,7 @@ class CompositeTypesTest(_base.MappedTest):
                 self.x2val = x2
                 self.x3 = x3
                 self.x4 = x4
+            __hash__ = None
             def __eq__(self, other):
                 return other.x1val == self.x1val and other.x2val == self.x2val and other.x3 == self.x3 and other.x4 == self.x4
             def __ne__(self, other):
@@ -1814,6 +1825,7 @@ class CompositeTypesTest(_base.MappedTest):
                 self.y = y
             def __composite_values__(self):
                 return [self.x, self.y]
+            __hash__ = None
             def __eq__(self, other):
                 return other.x == self.x and other.y == self.y
             def __ne__(self, other):
index 1cafd041a86c6e7605f16cdbdf8203a72b92b541..dc2c6d40f8a8c38058ebacb9c6eaefb3ad4cc3f8 100644 (file)
@@ -2,6 +2,7 @@
 from sqlalchemy.interfaces import ConnectionProxy
 from sqlalchemy.engine.default import DefaultDialect
 from sqlalchemy.engine.base import Connection
+from sqlalchemy import util
 import testing
 import re
 
@@ -72,7 +73,7 @@ class ExactSQL(SQLMatchRule):
         
         equivalent = _received_statement == sql
         if self.params:
-            if callable(self.params):
+            if util.callable(self.params):
                 params = self.params(context)
             else:
                 params = self.params
@@ -106,7 +107,7 @@ class RegexSQL(SQLMatchRule):
 
         equivalent = bool(self.regex.match(_received_statement))
         if self.params:
-            if callable(self.params):
+            if util.callable(self.params):
                 params = self.params(context)
             else:
                 params = self.params
@@ -148,7 +149,7 @@ class CompiledSQL(SQLMatchRule):
         
         equivalent = self.statement == _received_statement
         if self.params:
-            if callable(self.params):
+            if util.callable(self.params):
                 params = self.params(context)
             else:
                 params = self.params
index 912d7eb4d0066956a186d87a87a4005d2f2f5f8b..8eb885829c95a2950ec98451c4abe7dda9fd1fcc 100644 (file)
@@ -36,6 +36,7 @@ __author__ = "Steve Purcell"
 __email__ = "stephen_purcell at yahoo dot com"
 __version__ = "#Revision: 1.63 $"[11:-2]
 
+from sqlalchemy.util import callable
 import time
 import sys
 import traceback
@@ -52,22 +53,6 @@ __all__ = ['TestResult', 'TestCase', 'TestSuite', 'TextTestRunner',
 __all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases'])
 
 
-##############################################################################
-# Backward compatibility
-##############################################################################
-if sys.version_info[:2] < (2, 2):
-    False, True = 0, 1
-    def isinstance(obj, clsinfo):
-        import __builtin__
-        if type(clsinfo) in (tuple, list):
-            for cls in clsinfo:
-                if cls is type: cls = types.ClassType
-                if __builtin__.isinstance(obj, cls):
-                    return 1
-            return 0
-        else: return __builtin__.isinstance(obj, clsinfo)
-
-
 ##############################################################################
 # Test framework core
 ##############################################################################
@@ -482,7 +467,6 @@ class TestLoader:
     criteria and returning them wrapped in a Test
     """
     testMethodPrefix = 'test'
-    sortTestMethodsUsing = cmp
     suiteClass = TestSuite
 
     def loadTestsFromTestCase(self, testCaseClass):
@@ -556,6 +540,7 @@ class TestLoader:
     def getTestCaseNames(self, testCaseClass):
         """Return a sorted sequence of method names found within testCaseClass
         """
+
         def isTestMethod(attrname, testCaseClass=testCaseClass, prefix=self.testMethodPrefix):
             return attrname.startswith(prefix) and callable(getattr(testCaseClass, attrname))
         testFnNames = filter(isTestMethod, dir(testCaseClass))
@@ -563,8 +548,7 @@ class TestLoader:
             for testFnName in self.getTestCaseNames(baseclass):
                 if testFnName not in testFnNames:  # handle overridden methods
                     testFnNames.append(testFnName)
-        if self.sortTestMethodsUsing:
-            testFnNames.sort(self.sortTestMethodsUsing)
+        testFnNames.sort()
         return testFnNames
 
 
@@ -578,7 +562,6 @@ defaultTestLoader = TestLoader()
 
 def _makeLoader(prefix, sortUsing, suiteClass=None):
     loader = TestLoader()
-    loader.sortTestMethodsUsing = sortUsing
     loader.testMethodPrefix = prefix
     if suiteClass: loader.suiteClass = suiteClass
     return loader