#16563: Error pickling request.user
---------------------------------+------------------------------------
     Reporter:  zero.fuxor@…     |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  contrib.auth     |                  Version:  1.3
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by lukeplant):

 @kmike: That doesn't quite work, but it is close. My attached patch works
 in some cases, if someone can verify that it fixes the issue with a real
 User instance in environment showing the bug, I will commit it.

 I added the code to `SimpleLazyObject` not `LazyObject`, to minimize
 impact with other subclasses of `LazyObject`. `SimpleLazyObject` is not
 designed to be subclassed really - you are supposed to use it just by
 passing a callable to the constructor.

 There is one potential backwards compatibility concern here: if you had
 used a `SimpleLazyObject` with a callable that was itself pickleable, it
 would previously have been possible to pickle that `SimpleLazyObject`
 without the patch. Potentially, the object could have been pickled in the
 'lazy' state, without the callable having been called.

 However, I've tested this, and it seems that - for whatever reason -
 calling `pickle.dumps` causes the the callable to be called. Therefore,
 the object is not serialised in a 'lazy' state - it is always 'evaluated'.
 And this is just the same as it currently is, except we have made it
 explicit. The only difference now is that `SimpleLazyObject._setupfunc` is
 ''never'' available now after unpickling, but that shouldn't be a problem
 since it is never used.

 I'm therefore fairly confident that this patch shouldn't cause other
 problems.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16563#comment:20>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to