[Django] #29581: MultiValueDict behaviour does not match dict behaviour for single values

16 views
Skip to first unread message

Django

unread,
Jul 20, 2018, 8:28:39 AM7/20/18
to django-...@googlegroups.com
#29581: MultiValueDict behaviour does not match dict behaviour for single values
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
pvanagtmaal |
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Keywords: dict,
Triage Stage: | MultiValueDict
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
**Description:**
When using a MultiValueDict, retrieving the value for a key with only a
single value yields unexpected and inconsistent results compared to a
regular dictionary. See the code sample below.

{{{
>>> from django.utils.datastructures import MultiValueDict
>>> mvd = MultiValueDict()
>>> mvd['test'] = 1
>>> mvd['test']
1
>>> dict(mvd)['test']
[1]
}}}

**Expected:**
{{{ dict(mvd)['test'] }}} yields {{{1}}}, like {{{ mvd['test'] }}} does

**Actual:**
{{{ dict(mvd)['test'] }}} yields {{{[1]}}} instead

--
Ticket URL: <https://code.djangoproject.com/ticket/29581>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 20, 2018, 9:11:03 AM7/20/18
to django-...@googlegroups.com
#29581: MultiValueDict behaviour does not match dict behaviour for single values
-------------------------------------+-------------------------------------
Reporter: Piet van Agtmaal | Owner: nobody
Type: Bug | Status: closed
Component: Utilities | Version: 2.0
Severity: Normal | Resolution: wontfix

Keywords: dict, | Triage Stage:
MultiValueDict | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => wontfix


Comment:

I believe this is a duplicate of #12375. Even if the behavior could be
changed (I'm not sure what the implementation would look like), backwards
compatibility is probably more important. The resolution of the other
ticket was to add the `MultiValueDict.dict()` method in
97f22f29699476d5bcbbf599a3dba22909f4ec85.

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

Reply all
Reply to author
Forward
0 new messages