#3924: Caught an exception while rendering: 'ascii' codec can't decode byte 0xc3
in position 8: ordinal not in range(128)
-------------------------------------+--------------------------------------
   Reporter:  [EMAIL PROTECTED]  |                Owner:  hugo           
     Status:  reopened               |            Component:  Template system
    Version:  SVN                    |           Resolution:                 
   Keywords:                         |                Stage:  Accepted       
  Has_patch:  0                      |           Needs_docs:  0              
Needs_tests:  0                      |   Needs_better_patch:  0              
-------------------------------------+--------------------------------------
Comment (by [EMAIL PROTECTED]):

 Hello,
 I also have such error. I use newforms and I see that SelectDateWidget()
 raises UnicodeError. Before, I solved this problem fixing in
 django\newforms\util.py. I've removed 'smart_unicode_lazy'.
 {{{
 def smart_unicode(s):
     if isinstance(s, Promise):
         # The input is something from gettext_lazy or similar. We don't
 want to
         # translate it until render time, so defer the conversion.
 
         # return smart_unicode_lazy(s)
         return smart_unicode_immediate(s)
     else:
         return smart_unicode_immediate(s)
 
 }}}
 I've upgraded Django till 4939 rev. And I see the problem still exists. So
 I've just tried to make it like it was before:
 django\utils\encoding.py
 {{{
 #def smart_unicode(s):
 #    if isinstance(s, Promise):
         # The input is the result of a gettext_lazy() call, or similar. It
 will
         # already be encoded in DEFAULT_CHARSET on evaluation and we don't
 want
         # to evaluate it until render time.
         # FIXME: This isn't totally consistent, because it eventually
 returns a
         # bytestring rather than a unicode object. It works wherever we
 use
         # smart_unicode() at the moment. Fixing this requires work in the
         # i18n internals.
 #        return s
 #    if not isinstance(s, basestring,):
 #        if hasattr(s, '__unicode__'):
 #            s = unicode(s)
 #        else:
 #            s = unicode(str(s), settings.DEFAULT_CHARSET)
 #    elif not isinstance(s, unicode):
 #        s = unicode(s, settings.DEFAULT_CHARSET)
 #    return s
 
 def smart_unicode(s):
     if isinstance(s, Promise):
         # The input is something from gettext_lazy or similar. We don't
 want to
         # translate it until render time, so defer the conversion.
         return smart_unicode_immediate(s)
     else:
         return smart_unicode_immediate(s)
 
 def smart_unicode_immediate(s):
     if not isinstance(s, basestring):
         if hasattr(s, '__unicode__'):
             s = unicode(s)
         else:
             s = unicode(str(s), settings.DEFAULT_CHARSET)
     elif not isinstance(s, unicode):
         s = unicode(s, settings.DEFAULT_CHARSET)
     return s
 }}}
 
 Everything works fine. I don't know what is wrong. Looking forward for
 some advice. Thanks.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3924#comment:13>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to