Browse files

This patch seems to solve this bug:


During the calculations of request parameters in ``patch`` (tastypie/, 'content_length' is
being calculated based on the length of an ascii version of ``patch_data``. When the json that was
being passed to WSGI was being made, simplejson was returning a JSON that contained a unicode
string.  The unicode JSON, having more bytes per character, was not being fully read into
_raw_post_data because ``content_length`` didn't account for the extra bytes in unicode. This caused
non-valid JSON to be sent to json.loads on the other side of the request. This patch forces the
created JSON to always be ascii.
  • Loading branch information...
1 parent f5ae8bf commit e7eb5fbd023628a3af26b095731daf8e31608f44 @uberj committed Aug 31, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 tastypie/
@@ -335,7 +335,7 @@ def to_json(self, data, options=None):
options = options or {}
data = self.to_simple(data, options)
- return simplejson.dumps(data, cls=json.DjangoJSONEncoder, sort_keys=True, ensure_ascii=False)
+ return simplejson.dumps(data, cls=json.DjangoJSONEncoder, sort_keys=True, ensure_ascii=True)
def from_json(self, content):

0 comments on commit e7eb5fb

Please sign in to comment.