Code

Changes between Initial Version and Version 1 of Ticket #5640


Ignore:
Timestamp:
09/29/07 05:55:15 (7 years ago)
Author:
mtredinnick
Comment:

Hiding genuine errors is not the solution here, so this patch can't go in. Porting an application is a one-time job, so I'm reluctant to even add a setting for this.

The solution is probably to write your own version of force_unicode and assign that to encoding.force_unicode during your porting phase. We might be able to make the error a bit more self-helpful, though.

Changing the title to reflect the real issue, since force_unicode should raise UnicodeDecodeError when there's a problem. That's not a bug; the data it's being given is invalid.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #5640

    • Property Patch needs improvement unset
    • Property Needs tests unset
    • Property Summary changed from utils.encoding.force_unicode should never throw UnicodeDecodeError to Request to improve error handling in utils.encoding.force_unicode.
    • Property Owner changed from nobody to mtredinnick
    • Property Needs documentation unset
    • Property Has patch unset
    • Property Triage Stage changed from Unreviewed to Design decision needed
  • Ticket #5640 – Description

    initial v1  
    11migrating a large django project to trunk version > 5609 (i.e. after Unicode branch was merged) can be very painful due to a bug(?!) in utils.encoding.force_unicode 
    22 
    3 basically, following the instructions here http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsTheQuickChecklist is the right thing to do, but it is very difficult in a larger project to catch all the strings that might need and u'' before them.  
     3basically, following the instructions here http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsTheQuickChecklist is the right thing to do, but it is very difficult in a larger project to catch all the strings that might need and {{{u''}}} before them.  
    44 
    55Make the slightest oversight, and you lose the ability to debug your models/views/templates as utils.encoding.force_unicode will throw an UnicodeDecodeError exception like this one: