#27521: QueryDict is inconsistently converted to kwargs between CPython and PyPy
-------------------------------------+-------------------------------------
Reporter: Mark | Owner: nobody
Heppner |
Type: Bug | Status: new
Component: Core | Version: 1.10
(Other) | Keywords: PyPy QueryDict
Severity: Normal | MultiValueDict
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{
from django.conf import settings
settings.configure()
from django.http.request import QueryDict
q = QueryDict('foo=bar&foo=baz')
def test(**kwargs):
print(kwargs)
test(**q)
}}}
In CPython 2.7, 3.4, and 3.5, this prints out `{u'foo': [u'bar',
u'baz']}`, with the value being set to a list. In PyPy 5.4 (2.7.10) and
5.6 (2.7.12), the value comes back as a single string, always picking the
last item `{u'foo': u'baz'}`. To clarify, the instance of `QueryDict` is
the same between the two, they both show the value as a list; it's only
different when converting to kwargs. From what I can tell, this
inconsistent behavior is present in Django 1.8, 1.9, and 1.10.
In PyPy, this can be fixed by first casting to a `dict`:
{{{
> test(**dict(q))
{u'foo': [u'bar', u'baz']}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27521>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.3cf96ac816f73b8c531b97fdae0f233d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.