Opened 8 years ago

Last modified 7 years ago

#16563 closed Bug

Error pickling request.user — at Version 4

Reported by: zero.fuxor@… Owned by: nobody
Component: contrib.auth Version: 1.3
Severity: Release blocker Keywords:
Cc: Torsten Bronger, kmike84@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jannis Leidel)

trying to pickle a request.user in trunk raises: TypeError, can't pickle function objects
Looking it shows that request.user is a SimpleLazyObject and it is a <lambda>, so it can not be pickled.

try:
    import cPickle as pickle
except:
    import pickle


def some_view(request):
    pickle.dumps(request.user) # raise type error
    …

Change History (4)

comment:1 Changed 8 years ago by Paul McMillan

Resolution: wontfix
Status: newclosed

Some things aren't pickleable. It's a known limitation at the Python level, and is unlikely to change. Is Django itself trying to do this somewhere? Is there an extremely good reason this should be possible? I'm closing this as wontfix. Please feel free to reply if you've got good answers to these questions.

comment:2 Changed 8 years ago by Chris Beaven

milestone: 1.4
Resolution: wontfix
Status: closedreopened
Triage Stage: UnreviewedDesign decision needed

I'm going to reopen for now due to the fact this is a regression in 1.4.

Previously, this was possible:

def my_view(request):
    obj = MyObj(user=request.user, amount=1)
    request.session['unsaved_obj'] = obj
    # ...

Now request.user has been changed to a SimpleLazyObject rather than changing the request class to actually lazily return the true user object, this will choke.
Maybe this is an acceptable regression, but it's something I tripped up on in a project recently.

comment:3 Changed 8 years ago by Russell Keith-Magee

Severity: NormalRelease blocker

If this is a regression, then it should be tracked as a release blocker.

comment:4 Changed 8 years ago by Jannis Leidel

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