|
@@ -12,42 +12,20 @@ import inspect
|
|
import sys
|
|
import sys
|
|
import types
|
|
import types
|
|
|
|
|
|
-import pickle as pypickle
|
|
|
|
try:
|
|
try:
|
|
- import cPickle as cpickle
|
|
|
|
|
|
+ import cPickle as pickle
|
|
except ImportError:
|
|
except ImportError:
|
|
- cpickle = None # noqa
|
|
|
|
|
|
+ import pickle
|
|
|
|
|
|
from .encoding import safe_repr
|
|
from .encoding import safe_repr
|
|
|
|
|
|
|
|
|
|
-if sys.version_info < (2, 6): # pragma: no cover
|
|
|
|
- # cPickle is broken in Python <= 2.6.
|
|
|
|
- # It unsafely and incorrectly uses relative instead of absolute imports,
|
|
|
|
- # so e.g.:
|
|
|
|
- # exceptions.KeyError
|
|
|
|
- # becomes:
|
|
|
|
- # celery.exceptions.KeyError
|
|
|
|
- #
|
|
|
|
- # Your best choice is to upgrade to Python 2.6,
|
|
|
|
- # as while the pure pickle version has worse performance,
|
|
|
|
- # it is the only safe option for older Python versions.
|
|
|
|
- pickle = pypickle
|
|
|
|
-else:
|
|
|
|
- pickle = cpickle or pypickle
|
|
|
|
-
|
|
|
|
#: List of base classes we probably don't want to reduce to.
|
|
#: List of base classes we probably don't want to reduce to.
|
|
unwanted_base_classes = (StandardError, Exception, BaseException, object)
|
|
unwanted_base_classes = (StandardError, Exception, BaseException, object)
|
|
|
|
|
|
-if sys.version_info < (2, 5): # pragma: no cover
|
|
|
|
-
|
|
|
|
- # Prior to Python 2.5, Exception was an old-style class
|
|
|
|
- def subclass_exception(name, parent, unused):
|
|
|
|
- return types.ClassType(name, (parent,), {})
|
|
|
|
-else:
|
|
|
|
|
|
|
|
- def subclass_exception(name, parent, module): # noqa
|
|
|
|
- return type(name, (parent,), {'__module__': module})
|
|
|
|
|
|
+def subclass_exception(name, parent, module): # noqa
|
|
|
|
+ return type(name, (parent,), {'__module__': module})
|
|
|
|
|
|
|
|
|
|
def find_nearest_pickleable_exception(exc):
|
|
def find_nearest_pickleable_exception(exc):
|