#3406: [patch] newforms: choices checking should unicode choices list before
comparing to a value
---------------------------------+------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Status: new | Component: django.newforms
Version: SVN | Resolution:
Keywords: unicode | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 1 | Needs_better_patch: 1
---------------------------------+------------------------------------------
Changes (by Michael Radziej <[EMAIL PROTECTED]>):
* stage: Design decision needed => Unreviewed
Comment:
I think I understood you perfectly. I argue that formfield.choices should
be a list of tuples of unicode strings. Well, you can do it this way or
either, it's Adrian's decisions, anyway.
But leaving this aside, I tried to reproduce your bug, but I cannot:
{{{
>>> u"bla" == "bla"
True
>>> u"a" in set(["a"])
True
}}}
Then I try with newforms:
{{{
>>> from django.newforms import *
>>> f=ChoiceField(choices=[("a","a"),("b","b")])
>>> f.clean(u"a")
u'a'
>>> f.clean(u"c")
django.newforms.util.ValidationError Traceback
(most recent call last)
/home/mir/src/kundebunt/<console>
/home/mir/lib/python/django/newforms/fields.py in clean(self, value)
357 valid_values = set([str(k) for k, v in self.choices])
358 if value not in valid_values:
--> 359 raise ValidationError(gettext(u'Select a valid choice.
%s is not one of the available choices.') % value)
360 return value
361
ValidationError: [u'Select a valid choice. c is not one of the available
choices.']
}}}
So, I this works for me. Without converting the choices to unicode. Can
you show me a way how to get this bug?
--
Ticket URL: <http://code.djangoproject.com/ticket/3406#comment:4>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---