[Django] #21555: ValidationError is not picklable

16 views
Skip to first unread message

Django

unread,
Dec 3, 2013, 6:14:39 PM12/3/13
to django-...@googlegroups.com
#21555: ValidationError is not picklable
-------------------------------+--------------------
Reporter: zanuxzan | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I have a use case where I'd like to pickle ValidationError however it
throws up as error:

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.

Django

unread,
Dec 4, 2013, 2:32:29 AM12/4/13
to django-...@googlegroups.com
#21555: ValidationError is not picklable
-------------------------------+------------------------------------

Reporter: zanuxzan | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by loic84):

* 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>

Django

unread,
Dec 5, 2013, 7:33:24 AM12/5/13
to django-...@googlegroups.com
#21555: ValidationError is not picklable
--------------------------+---------------------------------------------

Reporter: zanuxzan | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------+---------------------------------------------
Changes (by timo):

* component: Uncategorized => Forms
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/21555#comment:2>

Django

unread,
Dec 7, 2013, 7:06:28 AM12/7/13
to django-...@googlegroups.com
#21555: ValidationError is not picklable
--------------------------+---------------------------------------------
Reporter: zanuxzan | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------+---------------------------------------------
Changes (by Loic Bistuer <loic.bistuer@…>):

* 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>

Reply all
Reply to author
Forward
0 new messages