Opened 11 years ago

Closed 11 years ago

#5811 closed (fixed)

newforms UnicodeDecodeError when displaying ValidationError strings in unicode

Reported by: Mike Maravillo <maravillo@…> Owned by: nobody
Component: Internationalization Version: master
Severity: Keywords: UnicodeDecodeError newforms ascii codec ordinal not in range
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


UnicodeDecodeError at /users/add_edit/1/
'ascii' codec can't decode byte 0xe3 in position 26: ordinal not in range(128)
Request Method: 	POST
Request URL:
Exception Type: 	UnicodeDecodeError
Exception Value: 	'ascii' codec can't decode byte 0xe3 in position 26: ordinal not in range(128)
Exception Location: 	/usr/lib/python2.3/site-packages/django/newforms/ in _html_output, line 147
Python Executable: 	/usr/bin/python
Python Version: 	2.3.4

I'm getting the above error with the following code, when secret != secret2...

    def clean_password(self):
        if['secret'] !=['secret2']:
            raise forms.ValidationError(_('Passwords are not the same'))

    def clean(self,*args, **kwargs):
        return super(UserForm, self).clean(*args, **kwargs)

The attached patch is just a quick fix. I'm not really sure if this affects anything else since I'm just new to Django... Thanks.

Attachments (1) (691 bytes) - added by Mike Maravillo <maravillo@…> 11 years ago.
newforms patch

Download all attachments as: .zip

Change History (3)

Changed 11 years ago by Mike Maravillo <maravillo@…>

Attachment: added

newforms patch

comment:1 Changed 11 years ago by Thomas Güttler <hv@…>

Triage Stage: UnreviewedAccepted

force_unicode() is better than unicode() here. Some lines above this is used, too.

comment:2 Changed 11 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [7186]) Fixed #5811 -- Added an explicit conversion to unicode that was otherwise causing problems in some cases. Thanks, Mike Maravillo.

Note: See TracTickets for help on using tickets.
Back to Top