#28575: Model.DoesNotExist classes are not pickleable
-------------------------------------+-------------------------------------
     Reporter:  Rachel Tobin         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.11
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Rachel Tobin:

Old description:

> Example:
> {{{
> >>> import django
> >>> import pickle
> >>> pickle.dumps(django.contrib.auth.models.User.DoesNotExist)
> >>> PicklingError: Can't pickle <class
> 'django.contrib.auth.models.DoesNotExist'>: it's not found as
> django.contrib.auth.models.DoesNotExist
> }}}
>
> Note that *instances* of `Model.DoesNotExist` are pickleable as fixed
> here: https://code.djangoproject.com/ticket/17776. However the class
> itself is not.  This is particularly problematic when using the Django
> test runner with the `--parallel` option enabled when a
> `Model.DoesNotExist` exception is raised. The result of this is the test
> runner bailing with a `pickle.PicklingError`, making it exceptionally
> difficult to debug the cause of the `Model.DoesNotExist`.
>
> This could be fixed by changing the metaclass that is used here:
> https://github.com/django/django/blob/1.11.5/django/db/models/base.py#L76
> to use a custom metaclass with a `__reduce__` method. A patch is in
> progress for this.

New description:

 Example:
 {{{
 >>> import django
 >>> import pickle
 >>> pickle.dumps(django.contrib.auth.models.User.DoesNotExist)
 >>> PicklingError: Can't pickle <class
 'django.contrib.auth.models.DoesNotExist'>: it's not found as
 django.contrib.auth.models.DoesNotExist
 }}}

 Note that *instances* of `Model.DoesNotExist` are pickleable as fixed
 here: https://code.djangoproject.com/ticket/17776. However the class
 itself is not.  This is particularly problematic when using the Django
 test runner with the `--parallel` option enabled when a
 `Model.DoesNotExist` exception is raised. The result of this is the test
 runner bailing with a `pickle.PicklingError`, making it exceptionally
 difficult to debug the cause of the `Model.DoesNotExist`.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28575#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.77bf299e8c23c1be96315de39e7a0be9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to