Commits

ianb  committed 9fef7c1

Add Response.unicode_errors

  • Participants
  • Parent commits 0c6898f

Comments (0)

Files changed (2)

File docs/news.txt

 
 * Quiet Python 2.6 deprecation warnings.
 
+* Added an attribute ``unicode_errors`` to :class:`webob.Response` --
+  if set to something like ``unicode_errors='replace'`` it will decode
+  ``resp.body`` appropriately.  The default is ``strict`` (which was
+  the former un-overridable behavior).
+
 0.9.3
 -----
 

File webob/__init__.py

 
     default_content_type = 'text/html'
     default_charset = 'UTF-8'
+    unicode_errors = 'strict'
     default_conditional_response = False
 
     def __init__(self, body=None, status='200 OK', headerlist=None, app_iter=None,
             raise AttributeError(
                 "You cannot access Response.unicode_body unless charset is set")
         body = self.body
-        return body.decode(self.charset)
+        return body.decode(self.charset, self.unicode_errors)
 
     def _unicode_body__set(self, value):
         if not self.charset: