﻿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
27887	TypeError when namespaced urlconf included from non-namespaced one	Matt Westcott	nobody	"The fix for #27874 (on latest stable/1.11.x) causes `TypeError: sequence item 0: expected str instance, NoneType found` upon running `./manage.py check` when a namespaced urlconf is included within a non-namespaced one. To replicate:

project/urls.py:

{{{
from django.conf.urls import url, include
from foo import urls as foo_urls
urlpatterns = [
    url(r'x/', include(foo_urls)),
]
}}}

foo/urls.py:

{{{
from django.conf.urls import url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
]
}}}

Traceback:
{{{
Traceback (most recent call last):
  File ""./manage.py"", line 22, in <module>
    execute_from_command_line(sys.argv)
  File ""/home/vagrant/libs/django/django/core/management/__init__.py"", line 363, in execute_from_command_line
    utility.execute()
  File ""/home/vagrant/libs/django/django/core/management/__init__.py"", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/home/vagrant/libs/django/django/core/management/base.py"", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File ""/home/vagrant/libs/django/django/core/management/base.py"", line 330, in execute
    output = self.handle(*args, **options)
  File ""/home/vagrant/libs/django/django/core/management/commands/check.py"", line 68, in handle
    fail_level=getattr(checks, options['fail_level']),
  File ""/home/vagrant/libs/django/django/core/management/base.py"", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File ""/home/vagrant/libs/django/django/core/management/base.py"", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File ""/home/vagrant/libs/django/django/core/checks/registry.py"", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File ""/home/vagrant/libs/django/django/core/checks/urls.py"", line 43, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File ""/home/vagrant/libs/django/django/core/checks/urls.py"", line 67, in _load_all_namespaces
    namespaces.extend(_load_all_namespaces(pattern, current))
  File ""/home/vagrant/libs/django/django/core/checks/urls.py"", line 62, in _load_all_namespaces
    ':'.join(parents + (url.namespace,)) for url in url_patterns
  File ""/home/vagrant/libs/django/django/core/checks/urls.py"", line 63, in <listcomp>
    if getattr(url, 'namespace', None) is not None
TypeError: sequence item 0: expected str instance, NoneType found
}}}

It looks like this is due to a logic error in the line:

https://github.com/django/django/commit/0417bf47a6fd00d9a6a4c711780ce01f35f62d59#diff-2f7a72bccd989000993282b2a8c77b8aR66

If `pattern.namespace` is defined and equal to None, then `getattr(pattern, 'namespace', ()),` returns None, which fails on the subsequent `join` operation."	Bug	closed	Core (System checks)	1.11	Release blocker	fixed			Accepted	1	0	0	0	0	0
