diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-01-11 20:45:28 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-01-11 20:45:28 -0500 |
| commit | 70383385d2b2b9e697446e37b40cb9b5d0cf581f (patch) | |
| tree | dfd66c793e8ad8049c3d333816a56838b92d349c | |
| parent | b4fcdc19a8f3e75b70276bab59c77137b53c4847 (diff) | |
| download | sqlalchemy-70383385d2b2b9e697446e37b40cb9b5d0cf581f.tar.gz | |
some adjustments for py3k
| -rw-r--r-- | lib/sqlalchemy/exc.py | 2 | ||||
| -rw-r--r-- | test/engine/test_execute.py | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index 55205b274..4ce0bfe7f 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 512d9d1a3..361c38c2f 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): |
