Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Russell Keith-Magee authored April 11, 2010

Showing 1 changed file with 12 additions and 2 deletions. Show diff stats Hide diff stats

  1. 14  django/template/__init__.py
14  django/template/__init__.py
@@ -48,6 +48,7 @@
48 48
 >>> t.render(c)
49 49
 u'<html></html>'
50 50
 """
  51
+import imp
51 52
 import re
52 53
 from inspect import getargspec
53 54
 
@@ -979,10 +980,19 @@ def import_library(taglib_module):
979 980
     Verifies that the library contains a 'register' attribute, and
980 981
     returns that attribute as the representation of the library
981 982
     """
  983
+    # We need to be able to tell the difference between a tag library that
  984
+    # doesn't exist, and a tag library with errors in it.
  985
+    # find_module() finds, but doesn't actually load the module requested.
  986
+    # If it raises ImportError, it means the module doesn't exist.
  987
+    # If you then use load_module(), any ImportError is guaranteed to be
  988
+    # an actual import problem with the module.
  989
+    app_path, taglib = taglib_module.rsplit('.',1)
  990
+    app_module = import_module(app_path)
982 991
     try:
983  
-        mod = import_module(taglib_module)
984  
-    except ImportError:
  992
+        imp.find_module(taglib, app_module.__path__)
  993
+    except ImportError,e:
985 994
         return None
  995
+    mod = import_module(taglib_module)
986 996
     try:
987 997
         return mod.register
988 998
     except AttributeError:

0 notes on commit aed032d

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