#26831: Session serialisers should document limitations on values
------------------------------------------------+------------------------
               Reporter:  erikr                 |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Documentation         |        Version:  master
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  1                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  1
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 The JSON session serialiser in Django (the default) does not allow non-
 UTF8 bytes to be stored in session values. This fact is not documented,
 although it may not be entirely surprising as Django expects utf-8
 everywhere. However, for clarity it may still be better to mention this,
 probably under https://docs.djangoproject.com/en/dev/topics/http/sessions
 /#session-serialization

 Here's a specific example of what you can't do, because '\xd9' is not
 valid unicode:
 {{{
 >>> from django.contrib.sessions.backends.db import SessionStore
 >>> s = SessionStore()
 >>> s['foo'] = '\xd9'
 >>> s.save()
 ......
 UnicodeDecodeError: 'utf8' codec can't decode byte 0xd9 in position 0:
 unexpected end of data
 }}}

 I'm considering this a documentation bug, as according to my research
 there is no way to encode this non-utf8 data into JSON.

--
Ticket URL: <https://code.djangoproject.com/ticket/26831>
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/048.fc3f798f21aeab85f4a6926f1fad00cd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to