Opened 10 years ago
Closed 10 years ago
#26409 closed Bug (invalid)
Python 2.7.11 causes manage.py ValueError
| Reported by: | György Kiss | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | 1.9 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | yes |
Description
Python 2.7.11 causes this exception when running manage.py or django-admin.py:
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.
Change History (6)
comment:1 by , 10 years ago
| Summary: | Python 2.7.11 → Python 2.7.11 causes manage.py ValueError |
|---|
comment:2 by , 10 years ago
| Resolution: | → needsinfo |
|---|---|
| Status: | new → closed |
follow-up: 4 comment:3 by , 10 years ago
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.
comment:4 by , 10 years ago
| Resolution: | needsinfo |
|---|---|
| Status: | closed → new |
Replying to aaugustin:
There's likely an issue with the
choiceskwarg 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?
follow-up: 6 comment:5 by , 10 years ago
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.
comment:6 by , 10 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
| UI/UX: | set |
Replying to 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 forchoices.
As a consequence, I don't believe this is a bug in Django.
Yes, you are right.
We need a minimal example to reproduce the crash, otherwise we cannot determine what the problem is.