Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24600 closed Bug (fixed)

Accessing deleted keys in Context objects do not return empty strings (raises KeyError)

Reported by: Ed Patrick Tan Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: pat.keeps.looking.up@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In the template documentation on playing with context objects, it is showed that deleting the key foo then accessing it again returns an empty string.

What actually happens: a KeyError is raised:

>>> from django.template import Context
>>> c = Context({'foo': 'bar'})
>>> c['foo']
'bar'
>>> del c['foo']
>>> c['foo']
Traceback (most recent call last):
...
KeyError: 'foo'

Change History (4)

comment:1 by Ed Patrick Tan, 9 years ago

Cc: pat.keeps.looking.up@… added

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

Resolution: fixed
Status: newclosed

In 3acefce:

Fixed #24600 -- Fixed inaccurate example in template Context docs.

Thanks pattypatpat for the report.

comment:3 by Tim Graham <timograham@…>, 9 years ago

In 51e5e2e:

[1.7.x] Fixed #24600 -- Fixed inaccurate example in template Context docs.

Thanks pattypatpat for the report.

Backport of 3acefcefeb5283473ac35d7e842027814d57d574 from master

comment:4 by Tim Graham <timograham@…>, 9 years ago

In 9e87017a:

[1.8.x] Fixed #24600 -- Fixed inaccurate example in template Context docs.

Thanks pattypatpat for the report.

Backport of 3acefcefeb5283473ac35d7e842027814d57d574 from master

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