Should the template system try to be a bit smarter about TypeError?

Skip to first unread message

James Bennett

May 7, 2006, 5:28:14 PM5/7/06
While trying to answer a question in the IRC channel today, I was
poking around in the template system and noticed that resolve_variable
has a comment about a particularly odd "gotcha": because it catches
and silently hides a TypeError raised by calling a method without the
appropriate number of arguments, it also ends up catching and silently
hiding a TypeError raised by something going wrong within the method

Out of curiosity, what's the reasoning for this? Would we incur a
significant performance penalty by looking at the exception to see
whether it's complaining about the number of arguments (in which case
it should not propagate) or whether something else has gone wrong and
raised a TypeError (in which case the exception probably should
propagate and result in a 500 error)?

"May the forces of evil become confused on the way to your house."
-- George Carlin

Kieran Holland

May 7, 2006, 7:45:25 PM5/7/06
to Django developers
I don't understand why the TypeError needs to be caught at all. If the
wrong number of arguments are passed then it seems to me that something
is genuinely broken - is there some reason to mask it? FWIW I removed
that catch as part of #1400 and haven't missed it.


Reply all
Reply to author
0 new messages