#21729: DecimalField.to_python() fails on values with invalid unicode start byte -----------------------------------+-------------------- Reporter: brett_energysavvy | Owner: nobody Type: Bug | Status: new Component: Forms | Version: 1.5 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------------+-------------------- Consider the following example:
{{{ from django.forms import Form from django.forms.fields import DecimalField class MyForm(Form): field = DecimalField() data = {'field': '1\xac23'} form = MyForm(data) form.is_valid() # This will raise a DjangoUnicodeDecodeError instead of returning False and having a validation error on the 'field'. }}} I noticed this on Django 1.5, but it looks like it also reproes on Django 1.6. Upon investigation, it looks like smart_str was used in previous versions. Nowadays, it looks like smart_text can throw a DjangoUnicodeDecodeError in these cases. I believe this exception should be caught in the to_python code and go through the same codepath as when an exception is raised in the "Decimal(value)" code block. -- Ticket URL: <https://code.djangoproject.com/ticket/21729> Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/060.fcafb12114f299d2674252aa289422da%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.