﻿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
29698	Model Field._check_choices() crashes with TypeError on some invalid values.	Franck Michea	Franck Michea	"Model field checks ensure that the `choices` field contains only pairs of (real value, human readable value). To do this it unpacks the values, protecting against ValueError (example: not a pair but a three-value tuple), however it does not protect against TypeError (example: integer), which will look something like this trying to runserver:

{{{
Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10ee2f8c8>
Traceback (most recent call last):
  File "".../lib/python3.7/site-packages/django/utils/autoreload.py"", line 225, in wrapper
    fn(*args, **kwargs)
  File "".../lib/python3.7/site-packages/django/core/management/commands/runserver.py"", line 117, in inner_run
    self.check(display_num_errors=True)
  File "".../lib/python3.7/site-packages/django/core/management/base.py"", line 379, in check
    include_deployment_checks=include_deployment_checks,
  File "".../lib/python3.7/site-packages/django/core/management/base.py"", line 366, in _run_checks
    return checks.run_checks(**kwargs)
  File "".../lib/python3.7/site-packages/django/core/checks/registry.py"", line 71, in run_checks
    new_errors = check(app_configs=app_configs)
  File "".../lib/python3.7/site-packages/django/core/checks/model_checks.py"", line 27, in check_all_models
    errors.extend(model.check(**kwargs))
  File "".../lib/python3.7/site-packages/django/db/models/base.py"", line 1183, in check
    *cls._check_fields(**kwargs),
  File "".../lib/python3.7/site-packages/django/db/models/base.py"", line 1261, in _check_fields
    errors.extend(field.check(**kwargs))
  File "".../lib/python3.7/site-packages/django/db/models/fields/__init__.py"", line 1770, in check
    *super().check(**kwargs),
  File "".../lib/python3.7/site-packages/django/db/models/fields/__init__.py"", line 203, in check
    *self._check_choices(),
  File "".../lib/python3.7/site-packages/django/db/models/fields/__init__.py"", line 262, in _check_choices
    group_name, group_choices = choices_group
TypeError: cannot unpack non-iterable int object
}}}

Pull request coming right up."	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
