#9290 closed (worksforme)
List index out of range when invalid template tag is used
Reported by: | aneil | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Using an invalid template tag results in the generic 'list index out of range' error which doesn't show any information about the offending file or expression. E.g., if a template contains:
... {% invalid_template_tag %} ...
An error occurs at line 279 of django.template.__init__.py:
278 try: 279 compiled_result = compile_func(self, token) 280 except KeyError: 281 self.invalid_block_tag(token, command) 282 except TemplateSyntaxError, e: 283 if not self.compile_function_error(token,e): 291 raise
What seems to be happening is that self.invalid_block_tag(...) raises an error which gets caught by TemplateSyntaxError and which eventually leads to the generic 'list index out of range' error being reported in the Django error page.
This problem has also been reported to the BetterErrorMessages page.
Change History (2)
comment:1 by , 16 years ago
Needs documentation: | set |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
If the original reporter can still repeat this, please reopen, but include a short, complete template which demonstrates the problem and the full traceback that Django displays at the time (use the cut-and-paste view when copying the traceback). It's not clear from reading the code where the index error could be coming from and badri's example above shows that the simplest case doesn't trigger the problem. So if there's a generic error here, we need a lot more information to be able to replicate it.