﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
4593	Unicode error in newforms\forms.py	bjorn.swift@…	Malcolm Tredinnick	"When translating a project, I ran into a Unicode error in newforms. As it seems, the field label wasn't being `smart_unicode`-d. A small patch is attached to fix that problem.

(Actually, two patches. Fix the same problem, but in different functions. Don't know where you want the problem fixed - but method B is probably better.)

The same problem persists with help_text, although that doesn't seem as easy to fix. If one uses `help_text=gettext(""foo"")` everything works fine (as help_text is thrown through `smart_unicode` in `newform\fields.py`'s `Field.__init__()`). But if one uses `gettext_lazy`, `help_text` is a `Promise` instance, doesn't get encoded and an exception is raised when string formatting is done.

A dirty hack to avoid this could be to call `help_text`'s `__str__()` directly, that is change [browser:django/trunk/django/newforms/forms.py#5481#L136]

{{{
#!python
        help_text = help_text_html % field.help_text
}}}

to

{{{
#!python
        help_text = help_text_html % smart_unicode(field.help_text.__str__())
}}}

.. but this probably doesn't qualify as a fix ;) !!

Or, hmm. Well. Shouldn't field.help_text be escaped at this point anyway? So perhaps the line should be changed to 
{{{
#!python
        help_text = help_text_html % smart_unicode(escape(field.help_text))
}}}

Better add a third patch with this included.."		closed	Internationalization	dev		wontfix	unicode newforms		Unreviewed	1	0	0	0	0	0
