#3314: [patch] smart_unicode throws UnicodeDecodeError when got a instance with
utf-8 encoded string
----------------------------------------------------------------+-----------
   Reporter:  nesh <nesh [at] studioquattro [dot] co [dot] yu>  |               
 Owner:  adrian         
     Status:  new                                               |            
Component:  django.newforms
    Version:                                                    |           
Resolution:                 
   Keywords:                                                    |               
 Stage:  Accepted       
  Has_patch:  1                                                 |           
Needs_docs:  0              
Needs_tests:  1                                                 |   
Needs_better_patch:  1              
----------------------------------------------------------------+-----------
Changes (by [EMAIL PROTECTED]):

  * needs_better_patch:  0 => 1
  * needs_tests:  0 => 1
  * stage:  Unreviewed => Accepted

Comment:

 Hi Nesh--thanks for spotting this! I don't understand one thing about your
 patch, why do you first try to decode from ASCII and only use the
 DEFAULT_CHARSET when it fails? I'd simply do it like this:
 
 {{{
 def smart_unicode(s):
     if not isinstance(s, basestring):
         s = unicode(str(s), settings.DEFAULT_CHARSET)
     elif not isinstance(s, unicode):
         s = unicode(s, settings.DEFAULT_CHARSET)
     return s
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3314#comment:2>
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