From: Mike Bayer Date: Thu, 12 Jan 2012 01:45:28 +0000 (-0500) Subject: some adjustments for py3k X-Git-Tag: rel_0_7_5~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70383385d2b2b9e697446e37b40cb9b5d0cf581f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git some adjustments for py3k --- diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index 55205b2744..4ce0bfe7f4 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -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): diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 512d9d1a3b..361c38c2fe 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -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):