﻿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
26015	sitemap view can raise UnboundLocalError	Keryn Knight	Andrew Kuchev	"Given the following urlconf definition:
{{{
from django.contrib.sitemaps.views import sitemap
url(r'^sitemap.xml$', sitemap, {'sitemaps': {}}, name='is_broken')
}}}
any attempt to load that URL will raise:
{{{
UnboundLocalError at /sitemap.xml
local variable 'site' referenced before assignment
}}}
because [https://github.com/django/django/blob/master/django/contrib/sitemaps/views.py#L74 if hasattr(site, 'latest_lastmod')] attempts to access `site` which is only ever set if `for site in maps` yields at least one iteration.

It should instead return an empty urlset, or possibly raise an Http404 with an appropriate debug message."	Bug	closed	contrib.sitemaps	dev	Normal	fixed		django@…	Accepted	1	0	0	0	1	0
