#523 closed defect (fixed)

simplejson-2.0.1 causes unicode-vs-bytestring problems

Reported by: warner Owned by: warner
Priority: major Milestone: 1.3.0
Component: code Version: 1.2.0
Keywords: Cc:
Launchpad Bug:

Description

A new version of simplejson was released recently, and it appears that the behavior of simplejson.loads changed. Whereas loads used to always return unicode strings, now it will return a regular bytestring if the value will fit into one:

  • simplejson-1.9.2:
    >>> simplejson.loads('"a"')
    u'a'
    
  • simplejson-2.0.1:
    >>> simplejson.loads('"a"')
    'a'
    

So to be compatible with this newer version, Tahoe needs to carefully coerce the output of simplejson.loads and convert all the string-or-unicode objects into unicode objects.

Here is a list of the files that use simplejson.loads:

  • dirnode.py
  • web/directory.py
  • scripts/tahoe_cp.py
  • scripts/tahoe_mv.py
  • scripts/tahoe_ls.py
  • test/check_load.py
  • test/test_web.py
  • test/test_util.py
  • test/test_system.py

Change History (1)

comment:1 Changed at 2008-09-30T22:31:48Z by warner

  • Resolution set to fixed
  • Status changed from new to closed

Fixed, in 935d1856967cb18e. It looks like simplejson-2.0.0 introduced some speedups, one of which is to optimize decoding of strings that happen to be all-ascii, resulting in this behavior change.

Note: See TracTickets for help on using tickets.