Opened 7 years ago

Last modified 6 years ago

#28575 closed Bug

Model.DoesNotExist classes are not pickleable — at Version 3

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 Tim Graham)

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

*Instances* of Model.DoesNotExist are pickleable as fixed in #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 (3)

comment:1 by Rachel Tobin, 7 years ago

Type: UncategorizedBug

comment:2 by Rachel Tobin, 7 years ago

Description: modified (diff)

comment:3 by Tim Graham, 7 years ago

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