{{{
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 353, in
execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line
18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py",
line 115, in populate
app_config.ready()
File "/usr/local/lib/python2.7/site-
packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/usr/local/lib/python2.7/site-
packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/usr/local/lib/python2.7/site-
packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in
import_module
__import__(name)
File "/officecontrol/src/core/admin.py", line 45, in <module>
class UserChangeForm(forms.ModelForm):
File "/usr/local/lib/python2.7/site-packages/django/forms/models.py",
line 247, in __new__
opts.field_classes)
File "/usr/local/lib/python2.7/site-packages/django/forms/models.py",
line 172, in fields_for_model
formfield = f.formfield(**kwargs)
File "/usr/local/lib/python2.7/site-
packages/django/db/models/fields/__init__.py", line 1120, in formfield
return super(CharField, self).formfield(**defaults)
File "/usr/local/lib/python2.7/site-
packages/django/db/models/fields/__init__.py", line 884, in formfield
defaults['choices'] = self.get_choices(include_blank=include_blank)
File "/usr/local/lib/python2.7/site-
packages/django/db/models/fields/__init__.py", line 811, in get_choices
for choice, __ in choices:
ValueError: too many values to unpack
}}}
I can reproduce it every time. **Earlier python versions are not
affected.**
We have a custom User model and customized UserAdmin if it matters.
My dependencies:
{{{
django-crispy-forms==1.6.0
django-mptt==0.8.3
django-rest-swagger==0.3.5
django-solo==1.1.2
django-widget-tweaks==1.4.1
Django==1.9.4 # via django-mptt, django-rest-swagger
djangorestframework==3.3.2
MySQL-python==1.2.5
Pillow==3.1.1
pytz==2015.7
PyYAML==3.11 # via django-rest-swagger
uWSGI==2.0.12
}}}
It comes up when building with Docker `FROM python:2.7` and
`python:2.7.11` images.
I can't share code, because it's proprietary, but it would be too big to
show anyway.
--
Ticket URL: <https://code.djangoproject.com/ticket/26409>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26409#comment:1>
* status: new => closed
* resolution: => needsinfo
Comment:
We need a minimal example to reproduce the crash, otherwise we cannot
determine what the problem is.
--
Ticket URL: <https://code.djangoproject.com/ticket/26409#comment:2>
Comment (by aaugustin):
There's likely an issue with the `choices` kwarg of a field definition.
Unfortunately, due to technical limitations of my crystal ball, I cannot
guess much more.
--
Ticket URL: <https://code.djangoproject.com/ticket/26409#comment:3>
* status: closed => new
* resolution: needsinfo =>
Comment:
Replying to [comment:3 aaugustin]:
> There's likely an issue with the `choices` kwarg of a field definition.
Unfortunately, due to technical limitations of my crystal ball, I cannot
guess much more.
You sir have a pretty good crystal ball!
This line caused the issue:
{{{
timezone_name = models.CharField(_('timezone'), max_length=35,
choices=tuple(pytz.all_timezones),
default=settings.TIME_ZONE)
}}}
`pytz.all_timezones` is not a tuple of two-tuples just a single tuple.
Why does it work in Python 2.7.10 and don't in 2.7.11?
--
Ticket URL: <https://code.djangoproject.com/ticket/26409#comment:4>
Comment (by aaugustin):
Yes, that's the sort of thing I expected...
I'm not sure why this used to work. `tuple(pytz.all_timezones)` doesn't
contain 2-uples so it isn't a valid argument for `choices`.
As a consequence, I don't believe this is a bug in Django.
--
Ticket URL: <https://code.djangoproject.com/ticket/26409#comment:5>
* status: new => closed
* ui_ux: 0 => 1
* resolution: => invalid
Comment:
Replying to [comment:5 aaugustin]:
> Yes, that's the sort of thing I expected...
>
> I'm not sure why this used to work. `tuple(pytz.all_timezones)` doesn't
contain 2-uples so it isn't a valid argument for `choices`.
>
> As a consequence, I don't believe this is a bug in Django.
Yes, you are right.
--
Ticket URL: <https://code.djangoproject.com/ticket/26409#comment:6>