Template Tag modules that raise an ImportError are difficult to debug
|Reported by:||amccurdy||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have several template tag libraries that I register using the add_to_builtins function. While upgrading to Django 1.2, I found that one of these template tag libraries was raising an ImportError. The ImportError was hidden from me however, because django.template.import_library catches ImportError and simply returns None. The None value still gets added to the django.template.builtins module-level variable, which eventually ends up making it's way to the Parser class's add_library function. Parser.add_library references the .tags attribute without checking for None, raising an AttributeError. There's was no indication of which template tag library caused the error, making this a pain to track down.
I would suggest that django.template.import_library not mask the ImportError. If this breaks backwards compatibility, then at least raise the ImportError from django.template.add_to_builtins.
Change History (3)
comment:1 Changed 5 years ago by russellm
- milestone set to 1.2
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted