#28575: Model.DoesNotExist classes are not pickleable -------------------------------------+------------------------------------- Reporter: Rachel | Owner: nobody Tobin | Type: | Status: new Uncategorized | Component: Database | Version: 1.11 layer (models, ORM) | Severity: Normal | Keywords: Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- 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. -- Ticket URL: <https://code.djangoproject.com/ticket/28575> 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/050.3abdf65dbf13bbcc79ef151d6c5abe0c%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.