Browse Source

Fix regression: get_pickleable_exception does not handle Exception. Thanks Aaron Ross

Ask Solem 15 years ago
parent
commit
9a23efd6d2
2 changed files with 6 additions and 1 deletions
  1. 1 1
      celery/serialization.py
  2. 5 0
      celery/tests/test_backends/test_base.py

+ 1 - 1
celery/serialization.py

@@ -103,7 +103,7 @@ def get_pickleable_exception(exc):
                         exc.__class__.__name__,
                         getattr(exc, "args", []))
         return excwrapper
-
+    return exc
 
 def get_pickled_exception(exc):
     """Get original exception from exception pickled using

+ 5 - 0
celery/tests/test_backends/test_base.py

@@ -3,6 +3,7 @@ import types
 from celery.backends.base import BaseBackend, KeyValueStoreBackend
 from celery.serialization import find_nearest_pickleable_exception as fnpe
 from celery.serialization import UnpickleableExceptionWrapper
+from celery.serialization import get_pickleable_exception as gpe
 from django.db.models.base import subclass_exception
 
 
@@ -42,6 +43,10 @@ class TestPickleException(unittest.TestCase):
     def test_BaseException(self):
         self.assertTrue(fnpe(Exception()) is None)
 
+    def test_get_pickleable_exception(self):
+        exc = Exception("foo")
+        self.assertEquals(gpe(exc), exc)
+
     def test_unpickleable(self):
         self.assertTrue(isinstance(fnpe(Unpickleable()), KeyError))
         self.assertEquals(fnpe(Impossible()), None)