Opened 18 years ago

Last modified 16 years ago

#3192 closed enhancement

[patch] Noisier bugs in context processors — at Initial Version

Reported by: Jeremy Dunck <jdunck@…> Owned by: nobody
Component: Template system Version: dev
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I just spent an embarrassingly long time figuring out the cause of "'NoneType' object has no attribute 'has_key'" when rendering a template.

I had a buggy context processor which returned None under some conditions, which then made it onto the context stack.

It seems to me that Context.update could verify that it's getting an object that supports getitem since it counts on that (and give a helpful error if it's not the case), but I understand context needs to be high-performance, and generally update is called for context processors anyway.

Perhaps RequestContext.init could raise a TypeError.

Patch attached. Feel free to ignore if I'm the only one to be bitten by this. :-/

Change History (2)

by Jeremy Dunck <jdunck@…>, 18 years ago

by Jeremy Dunck <jdunck@…>, 18 years ago

Attachment: dict-to-update.diff added

Another diff in case preference is to enforce in Context.update rather than RequestContext.init

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