Ticket #13404: t13404.diff

File t13404.diff, 1.3 KB (added by Russell Keith-Magee, 15 years ago)

Possible fix for submodule detection

  • django/utils/module_loading.py

    diff -r 64614eb56330 django/utils/module_loading.py
    a b  
    22import imp
    33
    44def module_has_submodule(mod, submod_name):
    5     # If the module was loaded from an egg, __loader__ will be set and 
     5    # If the module was loaded from an egg, __loader__ will be set and
    66    # its find_module must be used to search for submodules.
    77    loader = getattr(mod, '__loader__', None)
    88    if loader:
    9         mod_path = "%s.%s" % (mod.__name__, submod_name)
    10         mod_path = mod_path[len(loader.prefix):]
     9        mod_path = "%s.%s" % (mod.__name__.rsplit('.',1)[-1], submod_name)
    1110        x = loader.find_module(mod_path)
    1211        if x is None:
    1312            # zipimport.zipimporter.find_module is documented to take
    14             # dotted paths but in fact through Pyton 2.7 is observed
     13            # dotted paths but in fact through Python 2.7 is observed
    1514            # to require os.sep in place of dots...so try using os.sep
    16             # if the dotted path version failed to find the requested 
     15            # if the dotted path version failed to find the requested
    1716            # submodule.
    1817            x = loader.find_module(mod_path.replace('.', os.sep))
    1918        return x is not None
Back to Top