Opened 18 years ago

Last modified 13 years ago

#3344 closed

newforms UnicodeEncodeError in EmailField on non-successful validation — at Initial Version

Reported by: bartekr Owned by: Adrian Holovaty
Component: Forms Version: dev
Severity: Keywords: UnicodeEncodeError EmailField gettext Polish Norwegian unicode unicode-branch
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

newforms EmailField causes UnicodeEncodeError exception in case when value isn't correct.

Exception Type: UnicodeEncodeError
Exception Value: 'ascii' codec can't encode character u'\u017a' in position 33: ordinal not in range(128)
Exception Location: /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/django/newforms/forms.py in _html_output, line 103

I spent some time for debugging and I found that what probably causes the error is:

        RegexField.__init__(self, email_re, max_length, min_length, gettext(u'Enter a valid e-mail address.'), required, widget, label, initial)

newforms/fields.py, line 267 (rev. 4386)

When for debug purposes I changed gettext(u'Enter a valid e-mail address.') to anything else (ex. gettext(u'aaa')), the problem didn't occur and the 'aaa' validation error message was displayed like it should. This is probably a problem with translation file or so, but I'm just a Python/django/gettext newbie and I'm just starting my adventure with all of them, so I'm unable to debug it more.

Change History (0)

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