﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
13603	module_has_submodule fails when package is of type module	Eruquen@…	nobody	"module_has_submodule in utils/module_loading.py fails if the package is a module:

{{{

Traceback (most recent call last):
  File ""/usr/local/lib/python2.5/site-packages/flup/server/fcgi_base.py"", line 574, in run
    protocolStatus, appStatus = self.server.handler(self)
  File ""/usr/local/lib/python2.5/site-packages/flup/server/fcgi_base.py"", line 1159, in handler
    result = self.application(environ, start_response)
  File ""/usr/local/lib/python2.5/site-packages/django/core/handlers/wsgi.py"", line 241, in __call__
    response = self.get_response(request)
  File ""/usr/local/lib/python2.5/site-packages/django/core/handlers/base.py"", line 142, in get_response
    return self.handle_uncaught_exception(request, resolver, exc_info)
  File ""/usr/local/lib/python2.5/site-packages/django/core/handlers/base.py"", line 177, in handle_uncaught_exception
    if resolver.urlconf_module is None:
  File ""/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py"", line 238, in _get_urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File ""/usr/local/lib/python2.5/site-packages/django/utils/importlib.py"", line 35, in import_module
    __import__(name)
  File ""/var/kunden/webs/ef134/dja/urls.py"", line 9, in <module>
    admin.autodiscover()
  File ""/usr/local/lib/python2.5/site-packages/django/contrib/admin/__init__.py"", line 35, in autodiscover
    if module_has_submodule(mod, 'admin'):
  File ""/usr/local/lib/python2.5/site-packages/django/utils/module_loading.py"", line 14, in module_has_submodule
    for entry in package.__path__:  # No __path__, then not a package.
AttributeError: 'module' object has no attribute '__path__'
}}}


Without any deeper understanding of the issue I ""patched"" the problem by adding:


{{{
    if not hasattr(package, '__path__'):
        return False
}}}

right before the for loop.
This may or may not be the best idea but it did end the downtime.


(This is 1.2.0 final.)"	Bug	closed	Utilities	dev	Normal	fixed		unlearned@…	Accepted	0	0	0	0	0	0
