]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
some adjustments for py3k
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 12 Jan 2012 01:45:28 +0000 (20:45 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 12 Jan 2012 01:45:28 +0000 (20:45 -0500)
lib/sqlalchemy/exc.py
test/engine/test_execute.py

index 55205b2744290b971e721e4ef8703007b47383fb..4ce0bfe7f4413c5c92218c8d51d0a1e2db40549a 100644 (file)
@@ -165,7 +165,7 @@ class StatementError(SQLAlchemyError):
         self.orig = orig
 
     def __reduce__(self):
-        return self.__class__, (self.message, self.statement, 
+        return self.__class__, (self.args[0], self.statement, 
                                 self.params, self.orig)
 
     def __str__(self):
index 512d9d1a3bbaf5e4a5a6901c9645aa1ad1f435a5..361c38c2fe04fff4617c0453779f653ba64e3272 100644 (file)
@@ -198,15 +198,17 @@ class ExecuteTest(fixtures.TestBase):
                 "Exception doesn't come back exactly the same from pickle")
     def test_stmt_exception_pickleable_plus_dbapi(self):
         raw = testing.db.raw_connection()
+        the_orig = None
         try:
             try:
                 cursor = raw.cursor()
                 cursor.execute("SELECTINCORRECT")
             except testing.db.dialect.dbapi.DatabaseError, orig:
-                pass
+                # py3k has "orig" in local scope...
+                the_orig = orig
         finally:
             raw.close()
-        self._test_stmt_exception_pickleable(orig)
+        self._test_stmt_exception_pickleable(the_orig)
 
     def _test_stmt_exception_pickleable(self, orig):
         for sa_exc in (
@@ -220,13 +222,13 @@ class ExecuteTest(fixtures.TestBase):
         ):
             for loads, dumps in picklers():
                 repickled = loads(dumps(sa_exc))
-                eq_(repickled.message, sa_exc.message)
+                eq_(repickled.args[0], sa_exc.args[0])
                 eq_(repickled.params, {"foo":"bar"})
                 eq_(repickled.statement, sa_exc.statement)
                 if hasattr(sa_exc, "connection_invalidated"):
                     eq_(repickled.connection_invalidated, 
                         sa_exc.connection_invalidated)
-                eq_(repickled.orig.message, orig.message)
+                eq_(repickled.orig.args[0], orig.args[0])
 
     def test_dont_wrap_mixin(self):
         class MyException(Exception, tsa.exc.DontWrapMixin):