For example, I'd expect the following to work:
{{{#!python
import pickle
from django.core.exceptions import ValidationError
pickle.loads(pickle.dumps(ValidationError('eggs', 'sausage')))
}}}
Results in:
{{{
TypeError: __init__() takes at least 2 arguments (1 given)
}}}
The reason for this is because ValidationError does not call super.
--
Ticket URL: <https://code.djangoproject.com/ticket/21555>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: loic@… (added)
* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
It's a good idea as PY2 can't pickle naive exceptions see:
http://bugs.python.org/issue1692335 (fix was backported all the way to
python 3.2).
Since we'd now be calling the constructor, I think it's good practice to
pass all arguments so the `args` attribute holds meaningful information.
I've completed the test suite to ensure the more complex scenarios like
nested `ValidationError`, or `Validation` with `error_dict` behave as
expected.
PR https://github.com/django/django/pull/2022.
--
Ticket URL: <https://code.djangoproject.com/ticket/21555#comment:1>
* component: Uncategorized => Forms
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/21555#comment:2>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"a8f4553aaecc7bc6775e0fd54f8c615c792b3d97"]:
{{{
#!CommitTicketReference repository=""
revision="a8f4553aaecc7bc6775e0fd54f8c615c792b3d97"
Fixed #21555 -- Made ValidationError pickable.
Thanks trac username zanuxzan for the report and original patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21555#comment:3>