[Django] #24271: Error message for fields.E005 does not specify that both 'actual value', 'human readable name' must be strings/'Actual Value should be able to be a non-string

667 views
Skip to first unread message

Django

unread,
Feb 3, 2015, 11:52:44 AM2/3/15
to django-...@googlegroups.com
#24271: Error message for fields.E005 does not specify that both 'actual value',
'human readable name' must be strings/'Actual Value should be able to be a
non-string
----------------------------------+--------------------
Reporter: AncientSwordRage | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
----------------------------------+--------------------
There is some
[https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L254
code] that checks your choice of choices is valid. At one point it checks
this:

{{{ isinstance(choice, six.string_types)}}}

Which checks that BOTH parts of the 2-tuple are strings (e.g. human
readable). But the error message just says:

"'choices' must be an iterable containing (actual value, human
readable name) tuples."

Which does not specify type in anyway, (e.g it doesn't say they must be
some kind of string).

Either the error should say that both parts must be strings (and thus
block some fields from using them e.g. integer fields), or only the
second element should be checked, thusly:

{{{
>>> choices = (
... (1, 'Primary'), (2, 'Secondary'), (3, 'Tertiary')
... )
>>> any(isinstance(choice, six.string_types) for choice in choices)
False
>>> any(isinstance(choice[1], six.string_types) for choice in choices)
True
>>>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24271>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 3, 2015, 4:41:32 PM2/3/15
to django-...@googlegroups.com
#24271: Error message for fields.E005 does not specify that both 'actual value',
'human readable name' must be strings/'Actual Value should be able to be a
non-string
----------------------------------+--------------------------------------
Reporter: AncientSwordRage | Owner: mbasanta
Type: Bug | Status: assigned

Component: Core (Other) | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by mbasanta):

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => mbasanta
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24271#comment:1>

Django

unread,
Feb 3, 2015, 7:30:44 PM2/3/15
to django-...@googlegroups.com
#24271: Error message for fields.E005 does not specify that both 'actual value',
'human readable name' must be strings/'Actual Value should be able to be a
non-string
----------------------------------+--------------------------------------
Reporter: AncientSwordRage | Owner: mbasanta
Type: Bug | Status: closed

Component: Core (Other) | Version: 1.7
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by knbk):

* status: assigned => closed
* resolution: => fixed


Comment:

Turns out to be a bug in the user's code, not in Django:
http://stackoverflow.com/questions/28304776/are-numerically-keyed-choices-
no-longer-possible-in-django-1-7

--
Ticket URL: <https://code.djangoproject.com/ticket/24271#comment:2>

Django

unread,
Feb 3, 2015, 7:32:33 PM2/3/15
to django-...@googlegroups.com
#24271: Error message for fields.E005 does not specify that both 'actual value',
'human readable name' must be strings/'Actual Value should be able to be a
non-string
----------------------------------+--------------------------------------
Reporter: AncientSwordRage | Owner: mbasanta
Type: Bug | Status: closed
Component: Core (Other) | Version: 1.7
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by knbk):

* resolution: fixed => invalid


Comment:

Whoops, I mean 'invalid', not 'fixed'. (I can't edit that, can I?)

--
Ticket URL: <https://code.djangoproject.com/ticket/24271#comment:3>

Reply all
Reply to author
Forward
0 new messages