#5875: Non-ascii chars in source code causing UnicodeEncodeError for default 500
error handler, resulting in non-descriptive traceback-only error page
-------------------------+--------------------------------------------------
Reporter:  [EMAIL PROTECTED]  |       Owner:  nobody        
  Status:  new           |   Component:  Core framework
 Version:  SVN           |    Keywords:                
   Stage:  Unreviewed    |   Has_patch:  0             
-------------------------+--------------------------------------------------
 Project developed for pre-unicode django version, not utilizing i18n and
 using national chars in source with iso-8859-1 encoding.

 Django configured for serving with DEFAULT_CHARSET and FILE_CHARSET set to
 "iso-8859-1".

 Django upgraded to current SVN, and the mod_apache error handler appears,
 giving !UnicodeEncodeError deep in Django.

 {{{
 Traceback (most recent call last):

   File "/usr/lib/python2.3/site-packages/django/core/servers/basehttp.py",
 line 279, in run
     self.finish_response()

   File "/usr/lib/python2.3/site-packages/django/core/servers/basehttp.py",
 line 317, in finish_response
     for data in self.result:

   File "/usr/lib/python2.3/site-packages/django/http/__init__.py", line
 332, in next
     chunk = chunk.encode(self._charset)

 UnicodeEncodeError: 'latin-1' codec can't encode characters in position
 5735-5737: ordinal not in range(256)
 }}}

 The core problem seems to be chars from the non-allowed range enter the
 unicode-only path for django, for example in the case of __str__ model
 methods not returning unicode.

 That is obviously a problem in itself, but should not trip Django up this
 badly.

 Other examples have also beed observed, but all relate to database or form
 data being touched by non-unicode strings.


 Catching !UnicodeEncodeError and using replace mechanism at least enables
 developer to find offending chars and convert code to unicode.
 I don't know if this patch does the right thing, but it gives a workable
 error message.


 See attached patch for details.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5875>
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