Opened 17 years ago

Last modified 13 years ago

#3344 closed

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

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 (last modified by Adrian Holovaty)

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 (3)

comment:1 by bartekr, 17 years ago

Just found that it happens only if settings.LANGUAGE_CODE == 'pl'

However, when settings.LANGUAGE_CODE == 'en' and after translation.activate( 'pl' ) - it DOES NOT happen (and I could except it happens, as most of values are translated to Polish).

comment:2 by bartekr, 17 years ago

Keywords: gettext Polish added

comment:3 by Adrian Holovaty, 17 years ago

Description: modified (diff)
Triage Stage: UnreviewedAccepted

Fixed formatting in description.

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