#30500: Error reporting returns a circular import error on a python formatting
error, and does not restart the development server
-------------------------------------+-------------------------------------
Reporter: Runner15 | Owner: (none)
Type: | Status: new
Uncategorized |
Component: Error | Version: 2.2
reporting | Keywords: error reporting,
Severity: Normal | error, circular import
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
In Django 2.2.1, a python formatting error, such as a NameError or
IndentationError will give the error shown below:
{{{
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/runner/.local/lib/python3.5/site-
packages/django/urls/resolvers.py", line 581, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/home/runner/.local/lib/python3.5/site-
packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/management/commands/runserver.py", line 117, in
inner_run
self.check(display_num_errors=True)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/runner/.local/lib/python3.5/site-
packages/django/urls/resolvers.py", line 398, in check
for pattern in self.url_patterns:
File "/home/runner/.local/lib/python3.5/site-
packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/runner/.local/lib/python3.5/site-
packages/django/urls/resolvers.py", line 588, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf
'runnertest.urls' does not appear to have any patterns in it. If you see
valid patterns in the file then the issue is probably caused by a circular
import.
}}}
This throws django.core.exceptions.ImproperlyConfigured error, with the
message that the main urls file does not appear to have any patters in it,
and if there are patterns then the issue is probably a circular import.
Neither of these are the problem, as it is just a simple line in the code
that is indented improperly, or a variable that is not assigned. When
this issue is fixed, the development server does not restart itself to
reflect this fix. It manually has to be quit and then restarted.
The code below is the same python formatting error in Django 2.1. It
shows the error at the end of the error reporting, and when the error is
fixed in the code, the development server restarts itself.
{{{
Unhandled exception in thread started by <function
check_errors.<locals>.wrapper at 0x7f03cb1029d8>
Traceback (most recent call last):
File "/home/runner/.local/lib/python3.5/site-
packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/management/commands/runserver.py", line 117, in
inner_run
self.check(display_num_errors=True)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/management/base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/checks/urls.py", line 40, in
check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "/home/runner/.local/lib/python3.5/site-
packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "/home/runner/.local/lib/python3.5/site-
packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/runner/.local/lib/python3.5/site-
packages/django/urls/resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "/home/runner/.local/lib/python3.5/site-
packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/runner/.local/lib/python3.5/site-
packages/django/urls/resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in
_call_with_frames_removed
File
"/mnt/c/Users/myName/documents/python/django/runnertest/runnertest/urls.py",
line 23, in <module>
path('air/', include('appName.urls')),
File "/home/runner/.local/lib/python3.5/site-
packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in
_call_with_frames_removed
File
"/mnt/c/Users/myName/documents/python/django/runnertest/appName/urls.py",
line 3, in <module>
from . import views
File
"/mnt/c/Users/myName/documents/python/django/runnertest/appName/views.py",
line 233, in <module>
a
NameError: name 'a' is not defined
}}}
This can be replicated by adding an extra space on a line in your views
file, or throwing a variable name that does not exist on its own line.
--
Ticket URL: <https://code.djangoproject.com/ticket/30500>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.09b1ad1d5768062e26a382365a48a5e3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.