diff --git a/django/template/__init__.py b/django/template/__init__.py
      
        
          
        
        
          
            | 
              a
             | 
            
              b
             | 
            
              
               
             | 
          
        
        
          
            | 50 | 50 | """ | 
          
          
            | 51 | 51 | import imp | 
          
          
            | 52 | 52 | import re | 
          
        
        
          
            |   | 53 | import sys | 
          
        
        
          
            | 53 | 54 | from inspect import getargspec | 
          
          
            | 54 | 55 |  | 
          
          
            | 55 | 56 | from django.conf import settings | 
          
        
        
          
            | … | 
            … | 
            
              
               
             | 
          
        
        
          
            | 982 | 983 |     """ | 
          
          
            | 983 | 984 |     # We need to be able to tell the difference between a tag library that | 
          
          
            | 984 | 985 |     # 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 | 986 |     app_path, taglib = taglib_module.rsplit('.',1) | 
          
          
            | 990 | 987 |     app_module = import_module(app_path) | 
          
          
            | 991 | 988 |     try: | 
          
        
        
          
            | 992 |   |         imp.find_module(taglib, app_module.__path__) | 
          
          
            | 993 |   |     except ImportError,e: | 
          
          
            | 994 |   |         return None | 
          
          
            | 995 |   |     mod = import_module(taglib_module) | 
          
          
            |   | 989 |         mod = import_module(taglib_module) | 
          
          
            |   | 990 |     except ImportError: | 
          
          
            |   | 991 |         # imp.find_module() can tell us if a module exists by raising | 
          
          
            |   | 992 |         # ImportError without loading it. | 
          
          
            |   | 993 |         # Problem is it isn't compatible with templatetag libraries contained | 
          
          
            |   | 994 |         # inside eggs so we need to investigate things further if it fails | 
          
          
            |   | 995 |         # making sure to use a custom loaders if it is present. | 
          
          
            |   | 996 |         importer = sys.path_importer_cache.get(app_module.__path__[0], None) or imp | 
          
          
            |   | 997 |         try: | 
          
          
            |   | 998 |             if importer.find_module(taglib, app_module.__path__) is not None: | 
          
          
            |   | 999 |                 # It is guaranteed to be an actual import problem with the module. | 
          
          
            |   | 1000 |                 raise | 
          
          
            |   | 1001 |         except ImportError: | 
          
          
            |   | 1002 |             # The module doesn't exist. | 
          
          
            |   | 1003 |             return None | 
          
        
        
          
            | 996 | 1004 |     try: | 
          
          
            | 997 | 1005 |         return mod.register | 
          
          
            | 998 | 1006 |     except AttributeError: |