diff -r 64614eb56330 django/utils/module_loading.py
a
|
b
|
|
2 | 2 | import imp |
3 | 3 | |
4 | 4 | def 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 |
6 | 6 | # its find_module must be used to search for submodules. |
7 | 7 | loader = getattr(mod, '__loader__', None) |
8 | 8 | 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) |
11 | 10 | x = loader.find_module(mod_path) |
12 | 11 | if x is None: |
13 | 12 | # 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 |
15 | 14 | # 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 |
17 | 16 | # submodule. |
18 | 17 | x = loader.find_module(mod_path.replace('.', os.sep)) |
19 | 18 | return x is not None |