Opened 7 years ago

Last modified 6 years ago

#28575 closed Bug

Model.DoesNotExist classes are not pickleable — at Version 2

Reported by: Rachel Tobin Owned by: nobody
Component: Database layer (models, ORM) Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Rachel Tobin)

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.

Change History (2)

comment:1 by Rachel Tobin, 7 years ago

Type: UncategorizedBug

comment:2 by Rachel Tobin, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top