Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#18315 closed Cleanup/optimization (fixed)

Document QueryDict.pop & popitem

Reported by: gcbirzan Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

All the 'regular' operations on QueryDict return a single value, with a 'list' variant for returning a list of items. pop() pops a list, popitem() for just one item. This is not only inconsistent, but also not documented.

I'd prefer a solution that makes pop return a single item, vs mentioning it in the docs, but that breaks backwards compatibility.

Change History (10)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

I'm not convinced this is a sufficient reason to break backwards compatibility.

comment:2 Changed 3 years ago by anonymous

This confused me to no end before I found out that doing QueryDictkey? would not return the same value as QueryDict.pop('key'). This hardly seems like it conform with other uses of pop.

comment:3 Changed 3 years ago by _ado

Given a QueryDict d={'k':['a', 'b'], 'v':['1', '2']} then d.get('k')='a', but d.pop('k')=['a', 'b']
I've been using pop() to get me the list of values. Changing the functionality would be a backwards compatibility problem, indeed. I recommend to update the documentation instead.

comment:4 Changed 2 years ago by aaugustin

  • Type changed from Uncategorized to Cleanup/optimization

comment:5 Changed 2 years ago by aaugustin

  • Triage Stage changed from Design decision needed to Accepted

OK, let's fix this.

comment:6 Changed 2 years ago by timo

  • Component changed from HTTP handling to Documentation
  • Easy pickings set
  • Summary changed from QueryDict.pop is inconsistent to Document QueryDict.pop & popitem

comment:7 Changed 2 years ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In fdef471912022dd5d65946fa6f86adbc3c60f630:

[1.5.x] Fixed #18315 -- Documented QueryDict.popitem and QueryDict.pop

Thanks gcbirzan for the report.

Backport of 8c9240222f from master

comment:8 Changed 2 years ago by Tim Graham <timograham@…>

In f3a961f009afe4f1be4a5bb6d5c37c98c30fed41:

[1.4.x] Fixed #18315 -- Documented QueryDict.popitem and QueryDict.pop

Thanks gcbirzan for the report.

Backport of 8c9240222f from master

comment:9 Changed 2 years ago by Tim Graham <timograham@…>

In ec6928be3430e5113a888da43a9b386f85add40b:

[1.6.x] Fixed #18315 -- Documented QueryDict.popitem and QueryDict.pop

Thanks gcbirzan for the report.

Backport of 8c9240222f from master

comment:10 Changed 2 years ago by Tim Graham <timograham@…>

In 8c9240222fd882d9ae3819ff289989df1bcd05d7:

Fixed #18315 -- Documented QueryDict.popitem and QueryDict.pop

Thanks gcbirzan for the report.

Note: See TracTickets for help on using tickets.
Back to Top