﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27827	Raising InvalidTemplateLibrary completely masks out real exception in get_package_libraries	Kehinde Adewusi	Jacob Walls	"**Summary**
In django/template/backends/django.py, function get_package_libraries on line 119 completely masks out the ImportError and raises InvalidTemplateLibrary. This makes it incredibly difficult to debug application issues.
Probably better not to handle the exception in the first place since it only raises another type and inner exception looses the stack trace.

**To reproduce**
Create two apps e.g. form_utils and reports. 
Write a template tag in reports e.g. reports.templatetags.report_tags. (reports/templatetags/report_tags.py
Add a simple module in form_utils e.g. widgets.py. 
In widgets.py, import a none-existent module e.g. from django.forms.util import flatatt (was removed in > django 1.4)
import form_utils.widget in report_tags e.g. from form_utils.widgets import CalendarWidget
A quick way to reproduce the error would be to register some models with admin and navigate to /admin

The following error will be raised in get_package_libraries:

InvalidTemplateLibrary at /admin/login/

Invalid template library specified. ImportError raised when trying to load 'reports.templatetags.report_tags': No module named util

Request Method: 	GET
Request URL: 	http://localhost:2017/admin/login/?next=/admin/
Django Version: 	1.10.1
Exception Type: 	InvalidTemplateLibrary
Exception Value: 	
Invalid template library specified. ImportError raised when trying to load 'reports.templatetags.report_tags': No module named util
Exception Location: 	D:\repo\django110\lib\site-packages\django\template\backends\django.py in get_package_libraries, line 130

**However, if the exception was not caught and ""wrongly"" re-raised as an InvalidTemplateLibrary, the following errors would be printed:**

ImportError at /admin/login/
No module named util
Request Method: 	GET
Request URL: 	http://localhost:2017/admin/login/?next=/admin/
Django Version: 	1.10.1
Exception Type: 	ImportError
Exception Value: 	
No module named util
Exception Location: 	D:\repo\projects\evincehr\apps\form_utils\widgets.py in <module>, line 3

**The second behavior is more appropriate to debugging the error and the error would be quickly found.**
"	Cleanup/optimization	closed	Template system	dev	Normal	fixed	debugging		Accepted	1	0	0	0	0	0
