﻿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
4292	[unicode] django.utils.functional.lazy can't decorate functions with unicode results	Ivan Sagalaev <Maniac@…>	Malcolm Tredinnick	"Currently the admin page showing, say, a user object is broken for Russian translation. I've traced the reason -- a leaky abstraction of a lazy proxy object.

The proxy object created by 'lazy' should pretend to be an object of type returned by a decorated function. And this should work:

{{{
ugettext = lazy(ugettext, unicode)
s = ugettext(...) # a proxy object pretending to be a unicode instance
s = unicode(s)
}}}

But it doesn't work because unicode(s) checks:

  1. if s is an instance of unicode (it isn't)
  2. if s has {{{__unicode__}}} (it doesn't)
  3. if s has {{{__str___}}}, which it does (! unicode object itself has it)

Then it calls {{{__str__}}} on unicode object and it breaks for non-ascii characters.

I've created a fix but it seems a bit fragile because it creates a special case for unicode objects in lazy proxies.

P.S. The patch also contains two str -> smart_unicode conversions that don't strictly belong here but they are required for the testcase to work."		closed	Translations	other branch		fixed	unicode	Maniac@…	Accepted	0	0	0	0	0	0
