[Django] #26831: Session serialisers should document limitations on values

3 views
Skip to first unread message

Django

unread,
Jul 2, 2016, 8:11:11 AM7/2/16
to django-...@googlegroups.com
#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.

Django

unread,
Jul 2, 2016, 9:27:14 AM7/2/16
to django-...@googlegroups.com
#26831: Session serialisers should document limitations on values
--------------------------------------+------------------------------------

Reporter: erikr | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by claudep):

* stage: Unreviewed => Accepted


Comment:

A workaround could be to base64 encode, then decode at read, but still,
arbitrary raw bytes aren't JSON transmittable as is (AFAIK).

--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:1>

Django

unread,
Jul 3, 2016, 2:53:14 AM7/3/16
to django-...@googlegroups.com
#26831: Session serialisers should document limitations on values
-------------------------------------+-------------------------------------
Reporter: erikr | Owner: sadaf2605
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by sadaf2605):

* owner: nobody => sadaf2605
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:2>

Django

unread,
Jul 5, 2016, 10:54:48 AM7/5/16
to django-...@googlegroups.com
#26831: Session serialisers should document limitations on values
-------------------------------------+-------------------------------------
Reporter: erikr | Owner: sadaf2605
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_docs: 1 => 0
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/6874 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:3>

Django

unread,
Jul 12, 2016, 1:46:51 PM7/12/16
to django-...@googlegroups.com
#26831: Session serialisers should document limitations on values
-------------------------------------+-------------------------------------
Reporter: erikr | Owner: sadaf2605
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"1f82b857ceb75f2d7a68e79c6a00c30bfe7f1318" 1f82b85]:
{{{
#!CommitTicketReference repository=""
revision="1f82b857ceb75f2d7a68e79c6a00c30bfe7f1318"
Fixed #26831 -- Documented session data must be JSON encodable for
JSONSerializer.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:4>

Django

unread,
Jul 12, 2016, 1:47:06 PM7/12/16
to django-...@googlegroups.com
#26831: Session serialisers should document limitations on values
-------------------------------------+-------------------------------------
Reporter: erikr | Owner: sadaf2605
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"e6db7271547087034b1ee2db11676601706e67a3" e6db7271]:
{{{
#!CommitTicketReference repository=""
revision="e6db7271547087034b1ee2db11676601706e67a3"
[1.9.x] Fixed #26831 -- Documented session data must be JSON encodable for
JSONSerializer.

Backport of 1f82b857ceb75f2d7a68e79c6a00c30bfe7f1318 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:5>

Django

unread,
Jul 12, 2016, 1:47:07 PM7/12/16
to django-...@googlegroups.com
#26831: Session serialisers should document limitations on values
-------------------------------------+-------------------------------------
Reporter: erikr | Owner: sadaf2605
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"5d8332aaee77c8e598e93f67fa9061538d98b54f" 5d8332aa]:
{{{
#!CommitTicketReference repository=""
revision="5d8332aaee77c8e598e93f67fa9061538d98b54f"
[1.10.x] Fixed #26831 -- Documented session data must be JSON encodable
for JSONSerializer.

Backport of 1f82b857ceb75f2d7a68e79c6a00c30bfe7f1318 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26831#comment:6>

Reply all
Reply to author
Forward
0 new messages