On Mon, Jun 11, 2012 at 5:51 PM, Luke Plant <l.plant...@cantab.net> wrote: > > i.e. simplejson returns bytestrings if the string is ASCII (it returns > unicode objects otherwise), while json returns unicode objects always. >
This seemed strange to me because the standard library json shipping with python 2.7.3 is in fact simplejson 2.0.9, so I did some digging. It turns out that if the C extensions have been compiled and you pass a str instance to loads(), then you get that behavior in both versions. This isn't documented anywhere, but here's the offending pieces: http://hg.python.org/releasing/2.7.3/file/7bb96963d067/Modules/_json.c#l419 https://github.com/simplejson/simplejson/blob/master/simplejson/_speedups.c#L527 If the C extensions aren't enabled, or you pass a unicode string to loads(), then you get the "proper" behavior as documented. I'm not sure how you are triggering this optimized, iffy behavior in django.utils.simplejson though, without also triggering it in the standard library. Did you ever install simplejson with 'pip install simplejson' such that Django picked it up? Can you try running 'from django.utils import simplejson; print simplejson.__version__'? -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.