#33362: ALLOWED_HOSTS no longer accepts a non-list/tuple iterable.
------------------------------------------+------------------------
Reporter: Carlton Gibson | Owner: nobody
Type: Bug | Status: new
Component: HTTP handling | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
cdd0b213a825fcfe90ae93dcc554fba8c1e5ff5d added `ALLOWED_HOSTS` to the list
of `tuple_settings` that are checked to be lists or tuples in
`Settings.__init__()`.
This causes a regression with settings such as:
{{{
class AllowedHosts:
"""
An allowed hosts proxy, implementing SOME logic to determine
ALLOWED_HOSTS.
"""
DEBUG_ALLOWED_HOSTS = ["localhost", "127.0.0.1", "[::1]"]
def __iter__(self):
if settings.DEBUG:
yield from self.DEBUG_ALLOWED_HOSTS
yield "domain.com"
yield "domain.org"
yield from [
"other-domain.com",
"www.other-domain.com",
]
ALLOWED_HOSTS = AllowedHosts()
}}}
This works fine before Django 4.0 but raises afterwards:
{{{
raise ImproperlyConfigured("The %s setting must be a list or a tuple." %
setting)
django.core.exceptions.ImproperlyConfigured: The ALLOWED_HOSTS setting
must be a list or a tuple.
}}}
We could revert cdd0b213a825fcfe90ae93dcc554fba8c1e5ff5d, or else adjust
the test. I think the force of it is "`iterable()` but not a string"? 🤔
--
Ticket URL: <https://code.djangoproject.com/ticket/33362>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.13c1722b4beebfd591eda3becb19ff94%40djangoproject.com.