Template Tag modules that raise an ImportError are difficult to debug
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)
milestone: |
→ 1.2
|
Triage Stage: |
Unreviewed → Accepted
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Agreed that masking the import error is less than ideal. Accepting to 1.2 milestone because it's in an area that has changed significantly in 1.2, and we need to make sure that debugging info doesn't get any worse by upgrading.