#28037: Inconsistency on QueryDict.items and documentation
--------------------------------------------+------------------------
Reporter: Daniel F Moisset | Owner: nobody
Type: Uncategorized | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
There is a multiway inconsistency about the defined behaviour of
`QueryDict.items` (a similar thing happens for QueryDict.values`:
* The
[https://github.com/django/django/blob/master/django/utils/datastructures.py#L176
current implementation] actually returns a generator object (supporting
iteration only)
* The [https://docs.djangoproject.com/en/dev/ref/request-
response/#django.http.QueryDict.items documentation] says that it is "just
like the standard dictionary `items()` method", which in Python3 returns a
dict_items object (a [https://docs.python.org/3/library/stdtypes.html
#dictionary-view-objects view object], supporting set-like operations)
* But the example in the documentation 2 lines below that show a standard
python list (supporting indexing)
I see 2 different was to fix this:
1. Update the documentation and make explicit that a generator is returned
and that `Querydict` is a bit different than python dicts
2. Make `QueryDict` behave more like python by returning a set(). This
should not break backwards compatibility (a set is more general than a
generator), but use more memory (because the set must be fully built
instead of generated lazily)
I can provide patches for any of these options, but some core devs
recommended me getting an opinion of which is the right solution before
moving forward.
--
Ticket URL: <https://code.djangoproject.com/ticket/28037>
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.4ce1375b2c103878c376bbbc7cec8508%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.