Skip to content
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: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent b579350 commit aed032d0ac0f30e7e985f19536ac7a2cd2bc0233 @freakboy3742 freakboy3742 committed
Showing with 12 additions and 2 deletions.
  1. +12 −2 django/template/
14 django/template/
@@ -48,6 +48,7 @@
>>> t.render(c)
+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)
- mod = import_module(taglib_module)
- except ImportError:
+ imp.find_module(taglib, app_module.__path__)
+ except ImportError,e:
return None
+ mod = import_module(taglib_module)
return mod.register
except AttributeError:

0 comments on commit aed032d

Please sign in to comment.
Something went wrong with that request. Please try again.