Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #13311 -- Modified the tag library import process so it doesn't…

… mask import errors in the tag library itself. Thanks to amccurdy for the report, and Alex Gaynor for the suggested fix.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12944 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit aed032d0ac0f30e7e985f19536ac7a2cd2bc0233 1 parent b579350
@freakboy3742 freakboy3742 authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 django/template/__init__.py
View
14 django/template/__init__.py
@@ -48,6 +48,7 @@
>>> t.render(c)
u'<html></html>'
"""
+import imp
import re
from inspect import getargspec
@@ -979,10 +980,19 @@ def import_library(taglib_module):
Verifies that the library contains a 'register' attribute, and
returns that attribute as the representation of the library
"""
+ # We need to be able to tell the difference between a tag library that
+ # doesn't exist, and a tag library with errors in it.
+ # find_module() finds, but doesn't actually load the module requested.
+ # If it raises ImportError, it means the module doesn't exist.
+ # If you then use load_module(), any ImportError is guaranteed to be
+ # an actual import problem with the module.
+ app_path, taglib = taglib_module.rsplit('.',1)
+ app_module = import_module(app_path)
try:
- mod = import_module(taglib_module)
- except ImportError:
+ imp.find_module(taglib, app_module.__path__)
+ except ImportError,e:
return None
+ mod = import_module(taglib_module)
try:
return mod.register
except AttributeError:
Please sign in to comment.
Something went wrong with that request. Please try again.